jamesband Posted July 11, 2005 Posted July 11, 2005 $sPattern = I"\d\d[xX]\d\d" $sTest = "alias 01x21.avi" $nFlag = 1 $vResult = StringRegExp($sTest, $sPattern, $nFlag) Select Case @Error = 1 msgbox(0, "", "Error. Flag is bad. $vResult = ''") Case @Error = 2 msgbox(0, "", "Error. The pattern was invalid. $vResult = position in $sPattern where error occurred.") Case @Error = 0 if @Extended Then ; Success. Pattern matched. $vResult has the text from the groups or true (1), depending on flag. msgbox(0, "Match", $vResult) Else msgbox(0, "", "Failure. Pattern not matched. $vResult = '' or false (0), depending on flag.") EndIf EndSelect I cannot seem to get any resulting match, ie. '01x21'.... Can anyone help? Thanks
Nutster Posted July 11, 2005 Posted July 11, 2005 $sPattern = I"\d\d[xX]\d\d" $sTest = "alias 01x21.avi" $nFlag = 1 $vResult = StringRegExp($sTest, $sPattern, $nFlag) Select Case @Error = 1 msgbox(0, "", "Error. Flag is bad. $vResult = ''") Case @Error = 2 msgbox(0, "", "Error. The pattern was invalid. $vResult = position in $sPattern where error occurred.") Case @Error = 0 if @Extended Then ; Success. Pattern matched. $vResult has the text from the groups or true (1), depending on flag. msgbox(0, "Match", $vResult) Else msgbox(0, "", "Failure. Pattern not matched. $vResult = '' or false (0), depending on flag.") EndIf EndSelectI cannot seem to get any resulting match, ie. '01x21'....Can anyone help?Thanks<{POST_SNAPBACK}>What is the I doing in front of the string in line 1? Flag of 1 is trying to return an array of matching text, but in order to state what should be returned, parenthese (, ) need to be put around the pattern section to be returned. If you want to just return true or false, set $nFlag to 0.How about...$sPattern = "\d\d[xX]\d\d" $sTest = "alias 01x21.avi" $nFlag = 0 $vResult = StringRegExp($sTest, $sPattern, $nFlag) Select Case @Error = 1 msgbox(0, "", 'Error. Flag is bad. $vResult = "" ') Case @Error = 2 msgbox(0, "", "Error. The pattern was invalid. $vResult = position in $sPattern where error occurred.") Case @Error = 0 if @Extended Then ; Success. Pattern matched. $vResult has the text from the groups or true (1), depending on flag. msgbox(0, "Match", $vResult) Else msgbox(0, "", 'Failure. Pattern not matched. $vResult = "" or false (0), depending on flag.') EndIf EndSelector $sPattern = "(\d\d[xX]\d\d)" $sTest = "alias 01x21.avi" $nFlag = 1 $vResult = StringRegExp($sTest, $sPattern, $nFlag) Select Case @Error = 1 msgbox(0, "", 'Error. Flag is bad. $vResult = "" ') Case @Error = 2 msgbox(0, "", "Error. The pattern was invalid. $vResult = position in $sPattern where error occurred.") Case @Error = 0 if @Extended Then ; Success. Pattern matched. $vResult has the text from the groups or true (1), depending on flag. msgbox(0, "Match", $vResult[0]) Else msgbox(0, "", 'Failure. Pattern not matched. $vResult = "" or false (0), depending on flag.') EndIf EndSelect David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
jamesband Posted July 11, 2005 Author Posted July 11, 2005 That looks like it is getting it... thanks! JamesBand
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