BryanWall Posted January 9 Share Posted January 9 I've looked at: Below is some of the things I've tried for the ?: \Q?\E \? For the anything I've tried: .* [\s\S]* And I've tried all sorts of combinations with various parantheses, brackets, etc. None of it works for me. If I just do the anything part, it does remove stuff so I'm presuming my problem is with the ? part. I'm trying to remove those characters so that the $test string will match the $ExpDir string. Opt("WinTitleMatchMode",2) $hWndPP = WinGetHandle("POSPac MMS") $ExpDir = "D:\Applanix test\AutomationTest\Exports\W0205_ERSKINE_NJ\PostProcessed 1 of 1_W0205_ERSKINE_NJ" wLog($ExpDir) $test = ControlGetText($hWndPP,"","[NAME:TargetFileBox]") ; D:\Applanix test\AutomationTest\Exports\W0205_ERSKINE_NJ\PostProcessed 1 of 1_W0205_ERSKINE_NJ?ct wLog($test) ;~ $test = StringRegExpReplace($test,"\Q?\E[\s\S]*","") $test = StringRegExpReplace($test,"\?.*","") wLog(($test)) wLog merely writes to console with timestamp and newline Link to comment Share on other sites More sharing options...
Solution MagnumXL Posted January 11 Solution Share Posted January 11 "\?" will match your single question mark. To remove the it and the rest I would use something like "\?[^\n]+" which technically will remove only the rest of that line but not the return character at the end. Or "\?.*" which remove the ? and all characters after it, including new lines. Link to comment Share on other sites More sharing options...
jchd Posted January 11 Share Posted January 11 7 hours ago, MagnumXL said: "\?.*" which remove the ? and all characters after it, including new lines. I doubt it: dot (.) doesn't match newline sequences by default. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
BryanWall Posted January 11 Author Share Posted January 11 😨 #Region regEx Testing $testIn = "Anything?cd" wLog($testIn) $testOut = StringRegExpReplace($testIn,"\Q?\E[\s\S]*","") wLog(("\Q?\E[\s\S]* :" & $testOut)) $testOut = StringRegExpReplace($testIn,"\?.*","") wLog(("\?.* :" & $testOut)) $testOut = StringRegExpReplace($testIn,"\?[^\n]+","") wLog(("\?[^\n]+ :" & $testOut)) Exit #EndRegion Now all methods are working just fine. 1/11/2024 11:07:47 AM Anything?cd 1/11/2024 11:07:47 AM \Q?\E[\s\S]* :Anything 1/11/2024 11:07:47 AM \?.* :Anything 1/11/2024 11:07:47 AM \?[^\n]+ :Anything I have no idea why the same code was giving different outputs the other day. That is a little scary. Thank you for all of the help. 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