Replacement Text Reference
RegEx in a Nutshell
Regular expression for man pages to remove bullshit.
.
(regex)
(?:regex)
(?>regex)
Prevents backtracking back into the group after a match.
Positive Lookahead: (?=RegEx)
Negative Lookahead: (?!RegEx)
Positive Lookbehind: (?<=RegEx)
Negative Lookbehind: (?<!RegEx)
([0-9]{3})[-)./ ]*([0-9]{3})[-)./ ]*([0-9]{4}) $1-$2-$3
([0-9]{3})\D*([0-9]{3})\D([0-9]{4}) $1-$2-$3
EXPLANATION: Reformat all phone numbers to 123-456-7890 ([0-9]{3}) Three numbers, capture [-)./ ]* May or may not have hyphen(s), closing parenthesis, period(s), slash(es) or space(s) ([0-9]{3}) Three numbers, capture [-./ ]* May or may not have hyphen(s), period(s), slash(es) or space(s) ([0-9]{4}) Four numbers, capture
(?(?=regex)then|else)
IF lookaround (and) THEN RegEx ELSE RegEx.
Success if the lookaround and THEN match or the lookaround fails and the ELSE matches
(group)?
(?IF:THEN:ELSE)
([^ ]+)( )?
\L$1\E(?2:-)
(?#comment)
(?i)
Toggle On
(?-i)
Toggle Off