This post is written to help with basic regex patteren matching (plus for me to quickly refer something that I have already figured out).
Find spaces
Find space between 2 set of characters
\b \b
You can find tones of other patterns at Digital Fortress post
For practice, visit regexr.com
() all spaces (.) all spaces + one character before space
Well know tokens
| Taken | meaning |
|---|---|
| ^ | match at the beginning of string or line |
| () | group multiple tokens togather and create a capture group for extracting substring |
| \< \> | match characters < or > or etc. |
| * | all characters |
| . | match any character except line break |
| + | match one or more of precedding tokens |
| ? | Makes the preceding quantifier lazy, causing it to match as few characters as possible. By default, quantifiers are greedy, and will match as many characters as possible. see Make preceding token lazy |
| [ ] | match any character in this set |
| \s | space see remove leading space |
Some examples
Make preceding token lazy
Show b and next one or more characters (+ is one or more token).
b\w+?Results: >from b, be , bee, beee >be, bee , be will be selected as ? made the preceding token (+ ) lazy so instead of selecting multiple character the token ? has forced to be lazy and get satisfied with 1 character
Get all text before a character
^(.+?)│
where character is |
OR
^(.+)\.
where character is .Get all character within < and >
\<.*?\>remove leading space
^[\s]