Regular Expressions 101

Community Patterns

Single lone digits

1

Regular Expression
PCRE (PHP <7.3)

/
(?<!\d)(\d)(?!\d)
/
g

Description

Find single digits that are not part of an integer. For example, "27" should not match, but "27.1" will match the "1". "27.11" won't match.

Submitted by Conan Dombroski - 9 years ago