Read 04: Responsive Web Design and Regular Expressions - corey-marchand/data-structures-and-algorithms GitHub Wiki
Regular Expressions: Useful in extracting code information from any text
You can use this tool in almost all coding languages.
Ex:
Anchors β ^ and $
^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
Regex tutorial β A quick cheatsheet by examples Jonny Fox Jonny Fox Jun 22, 2017 Β· 6 min read
UPDATE! Check out my new REGEX COOKBOOK about the most commonly used (and most wanted) regex π
Regular expressions (regex or regexp) are extremely useful in extracting information from any text by searching for one or more matches of a specific search pattern (i.e. a specific sequence of ASCII or unicode characters).
Fields of application range from validation to parsing/replacing strings, passing through translating data to other formats and web scraping.
One of the most interesting features is that once youβve learned the syntax, you can actually use this tool in (almost) all programming languages ββ(JavaScript, Java, VB, C #, C / C++, Python, Perl, Ruby, Delphi, R, Tcl, and many others) with the slightest distinctions about the support of the most advanced features and syntax versions supported by the engines).
Letβs start by looking at some examples and explanations. Basic topics Anchors β ^ and $
^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
Quantifiers β * + ? and {}
abc* matches a string that has ab followed by zero or more c -> Try it!abc+ matches a string that has ab followed by one or more cabc? matches a string that has ab followed by zero or one cabc{2} matches a string that has ab followed by 2 cabc{2,} matches a string that has ab followed by 2 or more cabc{2,5} matches a string that has ab followed by 2 up to 5 ca(bc)* matches a string that has a followed by zero or more copies of the sequence bca(bc){2,5} matches a string that has a followed by 2 up to 5 copies of the sequence bc
OR operator β | or []
a(b|c) matches a string that has a followed by b or c -> Try it!a[bc] same as previous
Character classes β \d \w \s and .
\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!