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
~
\b004010H2[127][02379](?:A[12])?\b
~
g
Input 1
1
New
$str = "this is the code 004010H222A1 the rest is irrelevant"; $str = "the random number is 004010H223A2 ** anything else is irrelevant"; $str = "the last lottery number 004010H220A1 ~~ the rest is irrelevant"; $str = "yet another random sentence 004010H279A1 the rest is irrelevant"; $str = "any sentence before what i want 004010H279A1 the rest is irrelevant"; $str = "last winning number 004010H217~~~";
Extraction
$str = "this is the code 004010H222A1 the rest is irrelevant"; $str = "the random number is 004010H223A2 ** anything else is irrelevant"; $str = "the last lottery number 004010H220A1 ~~ the rest is irrelevant"; $str = "yet another random sentence 004010H279A1 the rest is irrelevant"; $str = "any sentence before what i want 004010H279A1 the rest is irrelevant"; $str = "last winning number 004010H217~~~";