I suggest using a site like regexr
to get familiar with RegEx expressions.
signs are the delimiters, meaning they mark the beginning and the end of the expression to check for.
I think how ever a few too many characters are escaped in the example provided by Joshy, not tested it myself on a board though.
Could you try the following examples:
Code: Select all
public function onConfigure($event)
$configurator = $event['configurator'];
'<a href="https://www.reddit.com/r/$1" target="_new">$0</a>',
'<a href="https://www.reddit.com/user/$1" target="_new">$0</a>',
are the delimiters, as explained above.
means look for the end of any word, a "end of word character". Such as spaces, commas, dots, new lines, etc..
look for the letter r (case sensitive!)
look for the
symbol, I believe that needs escaping, hence the prepended
is a capturing group, group 1, refered to in the next line for the replacement, see the
- The entire regex line is capture group 0, anything between () will then start counting up.
is the name of this particular capturing group
looks for a word, a word can consist of letter, digits and underscores (exactly what you are looking for)
is a quantifier, meaning it needs atleast 1 word or more to match.
Hope this helps.