Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(?:^|[^\d])[0]*(?<serial>1234)(?:[^\d]|$)
/
gm

Description

Will match strings with the desired number. For example 1234 but not 12345 or 41234. Will ignore leading zeros so 01234 for example will match.

Important. Replace 1234 in regex with the actual searched for number

Submitted by anonymous - 3 months ago