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
"
\*+\n \*\s+(?P<menu_name>PÄÄVALIKKO) \s\s\((?P<controller_model>iC1000)\s+ (?P<software_version>[0-9\.]+)\)\s+\*\n \*\s+Ala\_asema\s+(?P<substation_number>[0-9]+) \s+\*\n \*\-+\*\n \*\s+(Tulostus)\s+1\s+\*\n \*\s+(Asetus)\s+2\s+\*\n \*\s+(Ohjelmointi)\s+3\s+\*\n \*\s+(Hälytysten\skuittaus)\s+4\s+\*\n \*\s+(Ohjauksen\stila)\s+A\s+\*\n \*\s+(Impulssiarvo)\s+B\s+\*\n \*\s+(Säädön\sasetusarvo)\s+C\s+\*\n \*\s+(Mittauksen\srajat)\s+D\s+\*\n \*\s+(Asetusarvopisteen\sarvo)\s+E\s+\*\n \*\s+(Yhteyden\slopetus)\s+X\s+\*\n \*+
"
gmx
\*
matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\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)
Named Capture Group menu_name
(?P<menu_name>PÄÄVALIKKO)
PÄÄVALIKKO
matches the characters PÄÄVALIKKO literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
Named Capture Group controller_model
(?P<controller_model>iC1000)
iC1000
matches the characters iC1000 literally (case sensitive)
\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)
Named Capture Group software_version
(?P<software_version>[0-9\.]+)
Match a single character present in the list below
[0-9\.]
+ matches the previous token between one and unlimited 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)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
\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)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\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)
Ala
matches the characters Ala literally (case sensitive)
\_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
asema
matches the characters asema literally (case sensitive)
\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)
Named Capture Group substation_number
(?P<substation_number>[0-9]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\-
matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
5th Capturing Group
(Tulostus)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
6th Capturing Group
(Asetus)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
2 matches the character 2 with index 5010 (3216 or 628) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
7th Capturing Group
(Ohjelmointi)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
8th Capturing Group
(Hälytysten\skuittaus)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
9th Capturing Group
(Ohjauksen\stila)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
A matches the character A with index 6510 (4116 or 1018) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
10th Capturing Group
(Impulssiarvo)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
B matches the character B with index 6610 (4216 or 1028) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
11th Capturing Group
(Säädön\sasetusarvo)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
C matches the character C with index 6710 (4316 or 1038) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
12th Capturing Group
(Mittauksen\srajat)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
D matches the character D with index 6810 (4416 or 1048) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
13th Capturing Group
(Asetusarvopisteen\sarvo)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
E matches the character E with index 6910 (4516 or 1058) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
14th Capturing Group
(Yhteyden\slopetus)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
X matches the character X with index 8810 (5816 or 1308) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
\*
matches the character * with index 4210 (2A16 or 528) 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)
x modifier: extended. Spaces and text after a # in the pattern are ignored
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
gmx

Test String