Exit Posted March 13, 2009 Share Posted March 13, 2009 (edited) #include <Array.au3> $sTestString = "23,67no_digits_here ID=1234567890terminator xxxxx" $sPattern = "((\d|,)*)(?:.*ID=)((\d)*)(?:terminator)" $aResult = StringRegExp($sTestString, $sPattern, 1) If @error Then Exit MsgBox(0, "Error", "Variable >$aResult< not an array" & @CRLF & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended) _ArrayDisplay($aResult) When running this code, there are 4 lines in the array. I expected 2 lines: line0=23,67 line1=1234567890 What pattern will produce only 2 lines? Edited March 13, 2009 by forumer100 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Stilgar Posted March 13, 2009 Share Posted March 13, 2009 #include <Array.au3> $sTestString = "23,67no_digits_here ID=1234567890terminator xxxxx" $sPattern = "((\d|,)*)(?:.*ID=)((\d)*)(?:terminator)" $aResult = StringRegExp($sTestString, $sPattern, 1) If @error Then Exit MsgBox(0, "Error", "Variable >$aResult< not an array" & @CRLF & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended) _ArrayDisplay($aResult) When running this code, there are 4 lines in the array. I expected 2 lines: line0=23,67 line1=1234567890 What pattern will produce only 2 lines? Something like this: $sPattern = "(\d*,\d*).*?ID=(\d*)" jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Exit Posted March 13, 2009 Author Share Posted March 13, 2009 (edited) Something like this: $sPattern = "(\d*,\d*).*?ID=(\d*)"Yes, a step nearer to the goal. But sometimes, there is no comma in the first number. (only dollars, no cents) #include <Array.au3> $sTestString1 = "23,67no_digits_here ID=1234567890terminator xxxxx" $sTestString2 = "23no_digits_here ID=1234567890terminator xxxxx" $sPattern = "(\d*,\d*).*?ID=(\d*)" $aResult = StringRegExp($sTestString1, $sPattern, 1) If @error Then Exit MsgBox(0, "Error", "Variable >$aResult< not an array" & @CRLF & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended) _ArrayDisplay($aResult) $aResult = StringRegExp($sTestString2, $sPattern, 1) If @error Then Exit MsgBox(0, "Error", "Variable >$aResult< not an array" & @CRLF & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended) _ArrayDisplay($aResult) Edit: Got the answer myself. $sPattern = "([,0123456789]*).*?ID=(\d*)" Edited March 13, 2009 by forumer100 App: Au3toCmd UDF: _SingleScript() 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