Regular Expression is a special text string for describing a search pattern
Letters: abc
Digits: 123
Not Expression: ^
In some card games, the Joker is a wildcard and can represent any card in the deck.
Similarly, there is the concept of a wildcard, which is represented by the . (dot) metacharacter, and can match any single character (letter, digit, whitespace, everything).
.
E.g:
...
can match abc
, 234
, 3rZ
To escape a dot, (pattern match .
), use backlash \.
[abc]
: Only a
or b
or c
[^abc]
: Not a
b
, nor c
\d
: digit
\D
: not digit
\w
: word
\W
: not word
\s
: space
\S
: not space
https://www.regular-expressions.info/refshorthand.html
Number of occurance of character is specified with {}
sign
{4}
: repeat 4 times
{2,4}
: repeat from 2 to 4 times
E.g:
a{3,5}
*
: Zero or more repetitions
+
: at least one repetitions
We could use the above regular expression with a replacement pattern - $3$2$1$2$4 or \3\2\1\2\4.
RegexOne - Learn Regular Expression with simple, interactive exercies
Regxr - Live, responsive tool to learn, build and test regex
Regex: Quantifiers
Regex: Capturing Groups and Backreferences
Regex: Character Classes
Regex: Shorthand Character Classes
Some simple pattern