Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
`
I have created .* number <b>REQUK[0-9]{9,11}</b>.Before you ask me anything else I would like you provide some feedback on the topic just discussed.How did you enjoy this conversation with me?
`
gm
I have created
matches the characters I have created literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
number <b>REQUK
matches the characters number <b>REQUK literally (case sensitive)
Match a single character present in the list below
[0-9]
{9,11} matches the previous token between 9 and 11 times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
</b>
matches the characters </b> literally (case sensitive)
. matches any character (except for line terminators)
Before you ask me anything else I would like you provide some feedback on the topic just discussed
matches the characters Before you ask me anything else I would like you provide some feedback on the topic just discussed literally (case sensitive)
. matches any character (except for line terminators)
How did you enjoy this conversation with m
matches the characters How did you enjoy this conversation with m literally (case sensitive)
e
matches the character e with index 10110 (6516 or 1458) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.

Regular Expression
No Match

`
`
gm

Test String