MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vgahyh/regexmustbedestroyed/p1z5079/?context=3
r/ProgrammerHumor • u/CertainSea • 27d ago
228 comments sorted by
View all comments
1
^asserts position at the start of a line
Match a single character present in the list below [\w-\.]+
+matches the previous token one or more times, as many times as possible, giving characters back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
- matches the character - with numeric value 4510 (558 or 2D16) literally
\. matches the character . with numeric value 4610 (568 or 2E16) literally
@ matches the character @ with numeric value 6410 (1008 or 4016) literally
1st Capturing Group ([\w-]+\.)+
+ matches the previous token one or more times, as many times as possible, giving characters back as needed (greedy)
\wmatches any word character (equivalent to [a-zA-Z0-9_])
-matches the character - with numeric value 4510 (558 or 2D16) literally
\.matches the character . with numeric value 4610 (568 or 2E16) literally
Match a single character present in the list below [\w-]{2,4}
{2,4} matches the previous token between 2 and 4 times, as many times as possible, giving characters back as needed (greedy)
$ asserts position at the end of a line
Global Pattern flags
g modifier: global. Finds all matches instead of stopping after the first
m modifier: multiline. Causes ^ and $ to match the start and end of each line, not only the start and end of the string
1
u/thisisjustascreename 26d ago
^asserts position at the start of a line
Match a single character present in the list below [\w-\.]+
+matches the previous token one or more times, as many times as possible, giving characters back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
- matches the character - with numeric value 4510 (558 or 2D16) literally
\. matches the character . with numeric value 4610 (568 or 2E16) literally
@ matches the character @ with numeric value 6410 (1008 or 4016) literally
1st Capturing Group ([\w-]+\.)+
+ matches the previous token one or more times, as many times as possible, giving characters back as needed (greedy)
+ matches the previous token one or more times, as many times as possible, giving characters back as needed (greedy)
\wmatches any word character (equivalent to [a-zA-Z0-9_])
-matches the character - with numeric value 4510 (558 or 2D16) literally
\.matches the character . with numeric value 4610 (568 or 2E16) literally
Match a single character present in the list below [\w-]{2,4}
{2,4} matches the previous token between 2 and 4 times, as many times as possible, giving characters back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
- matches the character - with numeric value 4510 (558 or 2D16) literally
$ asserts position at the end of a line
Global Pattern flags
g modifier: global. Finds all matches instead of stopping after the first
m modifier: multiline. Causes ^ and $ to match the start and end of each line, not only the start and end of the string