Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
^i-(?:[a-f\d]{8}|[a-f\d]{17})$
"
gm
Input 1
1
New
I need a regex that will be able to match AWS EC2 instance IDs. Instance IDs have the following criteria: Can be either 8 or 17 characters Should start with i- Followed by either a-f or 0-9 Valid instance IDs are: i-ed3a2f7a i-096e0bec99b504f82 i-0cad9e810fbd12f4f Invalid instance IDs are e123g12 i-1fz5645m
Substitution
I need a regex that will be able to match AWS EC2 instance IDs. Instance IDs have the following criteria: Can be either 8 or 17 characters Should start with i- Followed by either a-f or 0-9 Valid instance IDs are: i-ed3a2f7a i-096e0bec99b504f82 i-0cad9e810fbd12f4f Invalid instance IDs are e123g12 i-1fz5645m