philkryder Posted February 2, 2016 Share Posted February 2, 2016 The brief reproducer below produces different results for StringInStr as contrasted with StringRegExp. I had expected both would find the string at offset 21. Why would StringRegExp give a value of 1 - with zero @error? ;;;;;;;;;;;;;;;;123456789012345678901 Local $sHTML = 'class="groupHeader">Special Circumstances</h2>' Local $sPattern = 'Special Circumstances' Local $ierrorSave Local $iextendedSave Local $iOffsetStringInString = StringInStr($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iOffsetStringInString>" & $iOffsetStringInString & @cr & $ierrorSave & @CR & $iextendedSave & @CR) Local $iOffsetStringRegExp = StringRegExp($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iOffsetStringRegExp>" & $iOffsetStringRegExp & @cr & $ierrorSave & @CR & $iextendedSave &@CR) Quote >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "R:\Operations\MacroTools\AutoIT\tests\testRegExp.au3" /UserParams +>17:54:50 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0 Keyboard:00010409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Pkryder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Pkryder\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files (x86)\AutoIt3 input:R:\Operations\MacroTools\AutoIT\tests\testRegExp.au3 +>17:54:51 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "R:\Operations\MacroTools\AutoIT\tests\testRegExp.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop $iOffsetStringInString>21 0 0 $iOffsetStringRegExp>1 0 0 +>17:54:51 AutoIt3.exe ended.rc:0 +>17:54:51 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.5771 Link to comment Share on other sites More sharing options...
JohnOne Posted February 2, 2016 Share Posted February 2, 2016 (edited) Perhaps one is 0 based while the other is 1 based. StringInStr is 1 based I believe, meaning the first character is 1, not 0. EDIT: mis-read. Edited February 2, 2016 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
iamtheky Posted February 2, 2016 Share Posted February 2, 2016 (edited) stringregexp return is 1 = it found a match 0 = No ErrorLevel set (or set to 0) 0 = there were no errors found so no offset of error (so either not set or set to 0) Edited February 2, 2016 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mikell Posted February 2, 2016 Share Posted February 2, 2016 Flag = $STR_REGEXPARRAYMATCH (1) @error=0 Array is valid. Check @extended for next offset Local $sHTML = 'class="groupHeader">Special Circumstances</h2>' Local $sPattern = 'Special Circumstances' Local $iOffsetStringInString = StringInStr($sHTML,$sPattern) ConsoleWrite("$iOffsetStringInString>" & $iOffsetStringInString & @CR) Local $iOffsetStringRegExp = StringRegExp($sHTML,$sPattern, 1) ;<<<< flag 1 $iextendedSave = @extended/2 ConsoleWrite("$iOffsetStringRegExp>" & $iextendedSave &@CR) Link to comment Share on other sites More sharing options...
philkryder Posted February 2, 2016 Author Share Posted February 2, 2016 thanks much - gosh, I read that and just didn't get it. Here though is an extended reproducer that exhibits more closely the problem I'm grappling with. In this case, I don't see why StringRegExp doesn't return a 1 for the last example. how can String in string match 'groupheader">Special Circumstances' But StringRegExp not match with 'groupheader">Special Circumstances' expandcollapse popup;;;;;;;;;;;;;;;;123456789012345678901 Local $sHTML $sHTML ='<h2 class="groupHeader">Special Circumstances</h2>' Local $sPattern = 'Special Circumstances' Local $ierrorSave Local $iextendedSave Local $iOffsetStringInString = StringInStr($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iOffsetStringInString>" & $iOffsetStringInString & @cr & $ierrorSave & @CR & $iextendedSave & @CR) Local $iMatchNoMatchIndicator = StringRegExp($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iMatchNoMatchIndicator>" & $iMatchNoMatchIndicator & @cr & $ierrorSave & @CR & $iextendedSave &@CR) $sPattern = 'r">Special Circumstances' Local $iOffsetStringInString = StringInStr($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iOffsetStringInString>" & $iOffsetStringInString & @cr & $ierrorSave & @CR & $iextendedSave & @CR) Local $iMatchNoMatchIndicator = StringRegExp($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iMatchNoMatchIndicator>" & $iMatchNoMatchIndicator & @cr & $ierrorSave & @CR & $iextendedSave &@CR) $sPattern = 'groupheader">Special Circumstances' Local $iOffsetStringInString = StringInStr($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iOffsetStringInString>" & $iOffsetStringInString & @cr & $ierrorSave & @CR & $iextendedSave & @CR) Local $iMatchNoMatchIndicator = StringRegExp($sHTML,$sPattern) $ierrorSave = @error $iextendedSave = @extended ConsoleWrite(@CR & "$iMatchNoMatchIndicator>" & $iMatchNoMatchIndicator & @cr & $ierrorSave & @CR & $iextendedSave &@CR) Quote >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "R:\Operations\MacroTools\AutoIT\tests\testRegExp.au3" /UserParams +>10:09:05 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0 Keyboard:00010409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Pkryder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Pkryder\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files (x86)\AutoIt3 input:R:\Operations\MacroTools\AutoIT\tests\testRegExp.au3 +>10:09:05 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "R:\Operations\MacroTools\AutoIT\tests\testRegExp.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop $iOffsetStringInString>25 0 0 $iMatchNoMatchIndicator>1 0 0 $iOffsetStringInString>22 0 0 $iMatchNoMatchIndicator>1 0 0 $iOffsetStringInString>12 0 0 $iMatchNoMatchIndicator>0 0 0 +>10:09:06 AutoIt3.exe ended.rc:0 +>10:09:06 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.5925 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