This guide seems helpful for visualising!
I also often use this site for testing out regular expressions.
Yeah it can seem quite confusing. Maybe using regexr to play around with a few of the examples from the guide may help.
I have some examples here:
This regex has the characters
and, so it will match where those characters are next to each other (in that order). (It will match anywhere that
\b is for ‘word boundary’ (the start or end of a word — where a word character is next to a non-word character, I think).
If I add
\b to the end of
and, it will match anything that has the characters
and and is followed by a word boundary. (So it will match anything that ends in ‘
And if I had
\b to the start of that, it will match anything that has a word boundary at the start, followed by the characters
and, followed by a word boundary. (Now it will only match the word ‘
(The website also has a reference on the left of the page, so you can check the different things that can be used.
\b is just one of them)