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

Pattern Description
[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
\A Begining of string
\z End of string
. Any char
\s Any whitespace char
\S Any non whitespace char
\d Any digit
\D Any non-digit sign
\w Any word character (letter, number, underscore)
\W Any non-word character
\b Boundary 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