Skip to main content

preg_match - online function

Perform a regular expression match. Use /g option (global match) to use function like preg_match_all. This tool it's a javascript function so result is generated by your browser and it's not sent across internet .

/
/
Make your pattern case insensitive.
Search until end of string, like preg_match_all
Result will be here...

Preg match cheatsheet

PatternDescription
[a-z]+Any string with small letters only
[A-Z]+Any string with uppercase letters only
[abc]Single letter a, b or c
[abc]$Single letter a, b or c at the end of the line
[abc]{2}Single letter a, b or c occurring at least twice
[abc]{2,5}Single letter a, b or c occurring at least twice and a maximum 5
^Begining of the line
$End of the line
\ABegining of string
\zEnd of string
.Any char
\sAny whitespace char
\SAny non whitespace char
\dAny digit
\DAny non-digit sign
\wAny word character (letter, number, underscore)
\WAny non-word character
\bBoundary character. For string: "This island is beautiful" if we use regex: \bis\b despite three occurences of is, only one will be found. This and island occurences are skipped:
This is is beautiful.

We use cookies on our website to enhance your user experience. We also use Google analytics and ads.

Click here to read more I've read it