regular expression examples
Example 1: regex usage
regex usage examples
Example 2: regular expression characters
regex = /d/;
regex = /D/;
regex = /S/;
regex = /s/;
regex = /w/;
regex = /W/;
regex = /b/;
Example 3: regex examples
a(b|c) matches a string that has a followed by b or c (and captures b or c) -> Try it!a[bc] same as previous, but without capturing b or c
Example 4: regex examples
\d matches a single character that is a digit -> Try it!\w matches a word character (alphanumeric character plus underscore) -> Try it!\s matches a whitespace character (includes tabs and line breaks). matches any character -> Try it!
Example 5: regex examples
^The matches any string that starts with The -> Try it!end$ matches a string that ends with end^The end$ exact string match (starts and ends with The end)roar matches any string that has the text roar in it
Example 6: regex examples
a(bc) parentheses create a capturing group with value bc -> Try it!a(?:bc)* using ?: we disable the capturing group -> Try it!a(?<foo>bc) using ?<foo> we put a name to the group -> Try it!