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
/
(<p>&#160<\/p>(\s?)+)+
/
1st Capturing Group
(<p>&#160<\/p>(\s?)+)+
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
<p>&#160<
matches the characters <p>&#160< literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
p>
matches the characters p> literally (case sensitive)
2nd Capturing Group
(\s?)+
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String