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)\[\[(?<firstlevelfolder>(?:assets|Bücher|Dokument|epsilon_notes|kontakte|literatur|Projekt|Test|Wissen|WV)(?:[\w_]*)\/)(?<bildpfad>[^\|\\\]]+)(\\\||\|)*(?<bildattribut>[^\]]*)\]\]
/
gm
(?i)
match the remainder of the pattern with the following effective flags: gmi
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case insensitive)
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case insensitive)
Named Capture Group firstlevelfolder
(?<firstlevelfolder>(?:assets|Bücher|Dokument|epsilon_notes|kontakte|literatur|Projekt|Test|Wissen|WV)(?:[\w_]*)\/)
Non-capturing group
(?:assets|Bücher|Dokument|epsilon_notes|kontakte|literatur|Projekt|Test|Wissen|WV)
1st Alternative
assets
assets
matches the characters assets literally (case insensitive)
2nd Alternative
Bücher
Bücher
matches the characters Bücher literally (case insensitive)
3rd Alternative
Dokument
Dokument
matches the characters Dokument literally (case insensitive)
4th Alternative
epsilon_notes
epsilon_notes
matches the characters epsilon_notes literally (case insensitive)
5th Alternative
kontakte
kontakte
matches the characters kontakte literally (case insensitive)
6th Alternative
literatur
literatur
matches the characters literatur literally (case insensitive)
7th Alternative
Projekt
Projekt
matches the characters Projekt literally (case insensitive)
8th Alternative
Test
Test
matches the characters Test literally (case insensitive)
9th Alternative
Wissen
Wissen
matches the characters Wissen literally (case insensitive)
10th Alternative
WV
WV
matches the characters WV literally (case insensitive)
Non-capturing group
(?:[\w_]*)
Match a single character present in the list below
[\w_]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
Named Capture Group bildpfad
(?<bildpfad>[^\|\\\]]+)
Match a single character not present in the list below
[^\|\\\]]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\| matches the character | with index 12410 (7C16 or 1748) literally (case insensitive)
\\ matches the character \ with index 9210 (5C16 or 1348) literally (case insensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case insensitive)
3rd Capturing Group
(\\\||\|)*
* matches the previous token between zero 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
1st Alternative
\\\|
\\ matches the character \ with index 9210 (5C16 or 1348) literally (case insensitive)
\| matches the character | with index 12410 (7C16 or 1748) literally (case insensitive)
2nd Alternative
\|
\| matches the character | with index 12410 (7C16 or 1748) literally (case insensitive)
Named Capture Group bildattribut
(?<bildattribut>[^\]]*)
Match a single character not present in the list below
[^\]]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case insensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case insensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case insensitive)
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...

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php