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
/
(namespace FeedStore\.Stores\.EF\.Entities\.Master)(\r\n|\n)({)(\r\n|\n)\s+(public partial class )\s*(\w+)
/
gm
1st Capturing Group
(namespace FeedStore\.Stores\.EF\.Entities\.Master)
namespace FeedStore
matches the characters namespace FeedStore literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
Stores
matches the characters Stores literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
EF
matches the characters EF literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
Entities
matches the characters Entities literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
Master
matches the characters Master literally (case sensitive)
2nd Capturing Group
(\r\n|\n)
1st Alternative
\r\n
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
2nd Alternative
\n
\n matches a line-feed (newline) character (ASCII 10)
3rd Capturing Group
({)
{ matches the character { with index 12310 (7B16 or 1738) literally (case sensitive)
4th Capturing Group
(\r\n|\n)
1st Alternative
\r\n
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
2nd Alternative
\n
\n matches a line-feed (newline) character (ASCII 10)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
5th Capturing Group
(public partial class )
public partial class
matches the characters public partial class literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
6th Capturing Group
(\w+)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
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.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String

Substitution

Processing...