That would be great. Even at many 'tutorials for beginners' they fail/omit to describe in plain spoken language what is happening in a formula or an expression.
Just going off from the virtualtags I showed you in the other thread
First thing first, everyone should try http://regexr.com/
, their cheatsheet was extremely helpful for me learning the regex syntax (I have no affiliation with the site).
General $rxreplace virtualtag formula: $RxReplace(<field>,"regex-pattern","replace-text")
Purpose: Title (Live) -> (Live)
Explanation (read the regex left to right):( )
= Capturing parentheses (or capture group). Content enclosed by them are captured into memory and can be recalled. In the above regex pattern, there are two captured groups. The content from the first capturing parentheses can be returned using "$1
" and contents from the second can be returned using "$2
". If there was a third, one would use $3, a fourth $4, so on and so forth.^
= Beginning of a line$
= End of the line.*
= . (any character), * (matches none or more of the proceeding token, here "."). .* = any number of characters going rightward. For example, ".*" by itself matches an entire line since it selects "." any character and "*" any number of characters. Other examples, K.* = selects K and every character following K to the end of the line; .*K = selects everything from the beginning of the line to the last K. .*?
= The "?
" means that the searching will be non-greedy, so .*?K = selects everything from the start of the line to the first
= The brackets here mean that any of the characters included within it will match the single character. Here, [Ll]ive means that the regex-pattern will find the words "Live" or "live". Likewise, [FfLl]ive will find the words Five, five, Live and live. On the flip side, adding a "^
" at the beginning of the bracket array, such as [^
Ll]ive, will result finding any four letter word having the last three letters "ive" while excluding "Live" and "live" from the results.
Note, if the two anchors ^
were not there, then [Ll]ive
will also select Live or live in the following words: Livermore, alive, olive, lively (you get the picture). In the regex-pattern at the top, [Ll]ive is bordered by parentheses, so we use that to demarcate it from other words we don't want to match up with our pattern. As for why the parenthesis are preceded by \
, read the next paragraph. Punctuation marks
= What if someone wants to find parenthesis or periods? Use escape characters. It means that having a "\" precede a character that is used in regex-patterns (like . ( ) [ ]), will mean that regex-pattern will search for those characters. From above, \(
means that regex-pattern will search for a parenthesis rather than establishing another capturing group. Likewise \.
means that a period will be searched rather than any character."$2"
= This is the replace-text portion of $RxReplace. Here, I'm telling it to replace <title> with whatever content is in the second captured group.