RegexTip's profile picture. Learn to use regular expressions by following RegexTip. From @JohnDCook.

Regular Expression

@RegexTip

Learn to use regular expressions by following RegexTip. From @JohnDCook.

Pinned

Four tips for learning regular expressions bit.ly/Xn7UH


\< represents a beginning word boundary and match a position between two tokens. Some engines don't support this.


\b matches a word boundary; \B matches anything but a word boundary.


Don't confuse \1 with $1. \1 is used inside a regex; $1 (in Perl) is used outside the regex after a match.


Many languages support Perl 5 regular expressions. For example, Microsoft .NET supports Perl 5 regex with some of its own extensions.


\d represents the numerical characters, or [0123456789]. Its complement is \D.


Using regular expressions in PowerShell johndcook.com/blog/powershel…


If you're going to work with regular expressions, it's worthwhile to learn Perl notation even if you don't intend to ever use Perl.


You can include comments inside a regex with (?# ... ). For example, /the\s+(?# One or more spaces)end


[a-z] matches all lower case letters. [-az] matches '-', 'a', or 'z'.


Perl stores the content of the previous match in $&, the text to the left of the match in $`, and the text to the right in $'.


Grep rewritten in Perl (and so it supports Perl regular expressions) johndcook.com/blog/2021/03/0…


If a dash is the first or last character in a character class, it is a literal dash and does not indicate a range.


Unusual applications of regular expressions cs.stackexchange.com/questions/1252…


'Perl Best Practices' recommends always using /xms on regexes. /x to allow whitespace & comments, /m and /s to handle newlines as expected.


Special characters and regular expressions johndcook.com/blog/2019/08/3…


vi and vim's engine uses \+ and \= in place of the more common + and ?.


Loading...

Something went wrong.


Something went wrong.