matchtext and replacetext regex parts not working as expecte
Posted: Sat Jul 02, 2016 10:54 am
============================================================
matchtext, return multiple matches?
Postby trenatos » Wed Dec 17, 2014 1:21 pm
I'm having trouble figuring out how to return multiple matches from matchtext.
I'm also wondering why the engine blows up on (?ig) ? (Setting regex to case insensitive and global, as per PCRE)
My regex works, built with https://www.regex101.com/ set to PCRE
=============================================================
I never saw any answer to this past post (ABOVE) and I am having the same issue without finding any forum entry that is related.
I am only getting one match using the matchtext function using the “foundTextVarsList” variables that match up with my regex captured numbered groups even though with ANY OTHER regex editor tool online or desktop, I get all three matches.
Question 1:
Is there any way to make the matchtext function work globally so I can get my three matches?
Question 2:
How to do a regex replace that lets me use my group numbers like \2 or $2 to selectively replace distinct matches with distinct info tailored to each specific match
ALL my other online or desktop regex replacement string tools seem based on my actual numbered groups like \2 or $2, related to my regex parenthesized groups.
When I use the actual group number in the replacement string such as “<img src=\2” or “<img src=$2” it actually replaces all my matches with the right image name and extension based on what regex group 2 had stipulated for EACH individual match.
In other words for each match the image and extension can be different as long it satisfies the group regex. All my other regex replacement tools don’t just replace the three matches with the SAME image name as is happening when I use the replaceText function and the replacement string uses one of the group names from the matchtext “foundTextVarsList” variables.
Not being able to do this, and having the three distinct image named matches replaced with the same name “kills” most of the power of what a regex replacement is supposed to do for one’s different matches. In other words, what a regex replacement is supposed to do is use the group expression to tailor the match replacement as long as the replacement string meets the requirements of the group regex.
Am I missing something here or am I supposed to be using other regex functions I am not aware of?
Meaning perhaps the process is more cumbersome than what I was expecting based on using different online and desktop regex match and replacement tools that ALL work as I had previously described.
Any guidance here would be very much appreciated. Thanks in advance to all.
matchtext, return multiple matches?
Postby trenatos » Wed Dec 17, 2014 1:21 pm
I'm having trouble figuring out how to return multiple matches from matchtext.
I'm also wondering why the engine blows up on (?ig) ? (Setting regex to case insensitive and global, as per PCRE)
My regex works, built with https://www.regex101.com/ set to PCRE
=============================================================
I never saw any answer to this past post (ABOVE) and I am having the same issue without finding any forum entry that is related.
I am only getting one match using the matchtext function using the “foundTextVarsList” variables that match up with my regex captured numbered groups even though with ANY OTHER regex editor tool online or desktop, I get all three matches.
Question 1:
Is there any way to make the matchtext function work globally so I can get my three matches?
Question 2:
How to do a regex replace that lets me use my group numbers like \2 or $2 to selectively replace distinct matches with distinct info tailored to each specific match
ALL my other online or desktop regex replacement string tools seem based on my actual numbered groups like \2 or $2, related to my regex parenthesized groups.
When I use the actual group number in the replacement string such as “<img src=\2” or “<img src=$2” it actually replaces all my matches with the right image name and extension based on what regex group 2 had stipulated for EACH individual match.
In other words for each match the image and extension can be different as long it satisfies the group regex. All my other regex replacement tools don’t just replace the three matches with the SAME image name as is happening when I use the replaceText function and the replacement string uses one of the group names from the matchtext “foundTextVarsList” variables.
Not being able to do this, and having the three distinct image named matches replaced with the same name “kills” most of the power of what a regex replacement is supposed to do for one’s different matches. In other words, what a regex replacement is supposed to do is use the group expression to tailor the match replacement as long as the replacement string meets the requirements of the group regex.
Am I missing something here or am I supposed to be using other regex functions I am not aware of?
Meaning perhaps the process is more cumbersome than what I was expecting based on using different online and desktop regex match and replacement tools that ALL work as I had previously described.
Any guidance here would be very much appreciated. Thanks in advance to all.