KSum Posted July 2, 2008 Share Posted July 2, 2008 Hello All,I am trying to get a tagged expression to work with StringRegExpReplace(), but can't put it together. Is it even possible with the function?Search for: (?i)\(.*\)test\(.*\)Replace with: \1NewTest\2Changing 16test17.txtTo 16NewTest17.txtandChanging 16Test17.txtTo 16NewTest17.txtI need to keep the case-insensitive portion, and this is only a simple example a more complex could be:Search for: (?i)\(.*\)test\(.*\)\.txtReplace with: \1NewTest\2.batChanging 16test17.txtTo 16NewTest17.batIf you are using the SciTe text editor, remove the (?i) from the search and you can see this work on the following list:1test2.txt2test3.txt3test4.txt4test5.txt5test6.txt6test7.txt7test8.txt8test9.txt9test10.txt10test11.txt11test12.txt12test13.txt13test14.txt14test15.txt15test16.txt16test17.txttest18.txttest19.txtTest.txtRegards,Karl Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 2, 2008 Share Posted July 2, 2008 Hello All, I am trying to get a tagged expression to work with StringRegExpReplace(), but can't put it together. Is it even possible with the function? Search for: (?i)\(.*\)test\(.*\) Replace with: \1NewTest\2 Changing 16test17.txt To 16NewTest17.txt and Changing 16Test17.txt To 16NewTest17.txt I need to keep the case-insensitive portion, and this is only a simple example a more complex could be: Search for: (?i)\(.*\)test\(.*\)\.txt Replace with: \1NewTest\2.bat Changing 16test17.txt To 16NewTest17.bat If you are using the SciTe text editor, remove the (?i) from the search and you can see this work on the following list: 1test2.txt 2test3.txt 3test4.txt 4test5.txt 5test6.txt 6test7.txt 7test8.txt 8test9.txt 9test10.txt 10test11.txt 11test12.txt 12test13.txt 13test14.txt 14test15.txt 15test16.txt 16test17.txt test18.txt test19.txt Test.txt Regards, Karl I couldn't figure out what the extra backslashes were for in your RegExp, so I just removed them, and this seems to work: Global $avInput[3] = ["1test2.txt", "2test3.txt", "3test4.txt"] For $n = 0 To UBound($avInput) - 1 ConsoleWrite("Input: " & $avInput[$n] & @LF) ConsoleWrite("Output: " & StringRegExpReplace($avInput[$n], "(?i)(.*)test(.*)", "\1NewTest\2") & @LF) Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
KSum Posted July 2, 2008 Author Share Posted July 2, 2008 The extra backlsahes were what the text editor uses to tag the expressions. I am not sure what I had when I used your version, which does work. Must have had some typo with that test.Thank you for the reply!Karl Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now