So, I jumped in and learned a number of useful expressions, especially[Drive],[FileName],[Path], [EmailAddress], etc., but I cannot seem to figure out how to get a group. And since I can't get a group, then I can't do a Replace.
So, I have provided some code samples. The first Replace function works fine with normal RegEx.
Can some one please provide the correct syntax for the vNeedles in the other three samples?
I know these simple examples can probably be done withMidStr and Position commands, but I am trying to understand the Easy Pattern syntax, so I thought if I understood these, then I can take it from there.
I am having trouble with placement of the [braces], (parentheses), the phrase [capture(...)], with a trailing comma and [capture(...) as 'varname' ] without the trailing comma after the closing brace "],"
I am sure my problem is defining vNeedle, but I need some help.
It looks like the captured group can be referred to [groupx] or as $x using 1-9 or a-z?
I am looking for a few examples of using captured groups as variables, and as replacement values.
============================================
Code: Select all
//Replace example Normal RegEx (Works OK)
Let>vHaystack=Today's magic word is ~FRED~, changed from MARY.
Let>vNeedle=~.*~
RegEx>vNeedle,vHaystack,0,vNeedleNo,vTotalNeedles,1,~SAM~,vFinalHaystack
MessageModal> Hope to see%CRLF%"Today's magic word is ~SAM~, changed from MARY".
MessageModal>New line is %vFinalHaystack%
//Replace example EasyPattern (Does not work)
Let>vHaystack=Today's magic word is ~FRED~, changed from MARY.
Let>vNeedle=~[capture(~ .*~)], ; Grab everything between tildes(~)
RegEx>vNeedle,vHaystack,1,vNeedleNo,vTotalNeedles,1,~SAM~,vFinalHaystack
MessageModal> Hope to see%CRLF%"Today's magic word is ~SAM~, changed from MARY".
MessageModal>New line is %vFinalHaystack%
//Get Group example EasyPattern (Does not exist)
//Macro Scheduler Normal Regex, does not seem to handle groups,MUST use Easy Pattern
//Get Group example EasyPattern (Does not work)
Let>vHaystack=abcdxyz~this is what I want~xyz987~along with this~ too
Let>vNeedle=~[capture(.*)],~ ; Grab everything between tildes
RegEx>vNeedle,vHaystack,1,vNeedleNo,vTotalNeedles,0,,
MessageModal> Hope to see%CRLF%"this is what I want"%CRLF% and%CRLF%"along with this"
MessageModal>Found %vTotalNeedles% matches.%CRLF%First match is %vNeedleNo_1%%CRLF%Second match is %vNeedleNo_2%..
EXIT>