Who Posted July 31, 2007 Share Posted July 31, 2007 I'm really suck into StringRegExp trouble. I have this PHP code : <?php $subject = "abcdef"; $pattern = '/^def/'; preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> Which will produce : Array ( [0] => Array ( [0] => def [1] => 0 ) ) And I get it into AutoIT : #include <Array.au3> $array = StringRegExp('abcdef', '/^def/') _ArrayDisplay($array) But nothing happens. Please I'm need your help. Link to comment Share on other sites More sharing options...
Toady Posted July 31, 2007 Share Posted July 31, 2007 Set a flag in StringRegExp... #include <Array.au3> $array = StringRegExp('abcdef', '/^def/',2) _ArrayDisplay($array) www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
Who Posted July 31, 2007 Author Share Posted July 31, 2007 Set a flag in StringRegExp... #include <Array.au3> $array = StringRegExp('abcdef', '/^def/',2) _ArrayDisplay($array) $array = StringRegExp('abcdef', '/^def/',2) for $i = 0 to UBound($array) - 1 msgbox(0, "Matches - " & $i, $array[$i]) Next I have tried as you told me but it doesn't work at all. The program shows nothing then . Can you give me another suggestion please ? Link to comment Share on other sites More sharing options...
Toady Posted July 31, 2007 Share Posted July 31, 2007 I suggest looking at the StringRegExp() function in the help file. It has a good description on how to use it. www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
Who Posted August 1, 2007 Author Share Posted August 1, 2007 When set the flag to 2, then the error is 1, which mean no matches in the array. I have tried a different test but it can't be helped. Can you explain more please ? Link to comment Share on other sites More sharing options...
MisterBates Posted August 1, 2007 Share Posted August 1, 2007 When set the flag to 2, then the error is 1, which mean no matches in the array. I have tried a different test but it can't be helped. Can you explain more please ?AutoIt RegExp matching is not the same syntax as PHP. Could you explain in a few sentences what the PHP matching is trying to do? Or what you are trying to do? ... so that we get some background and can suggest how to do it in AutoIt ... [u]MisterBates[/u]_____________________________________________________Suspend/Resume Windows ScreensaverWatchWindows - Window watcher/loggerUDF: Click systray menu/submenu itemsUDF: Outlook Express Folder/Message handling (+ example code)HowTo: Multiple icons in one compiled script Link to comment Share on other sites More sharing options...
Who Posted August 1, 2007 Author Share Posted August 1, 2007 AutoIt RegExp matching is not the same syntax as PHP. Could you explain in a few sentences what the PHP matching is trying to do? Or what you are trying to do? ... so that we get some background and can suggest how to do it in AutoIt ...After many tries I realized that the AutoIT Regexp doesn't have ending delimiter (/) like in PHP . After removing the two (/) and (/i) in my pattern, the results are right but I don't know whether this action can affect or not Link to comment Share on other sites More sharing options...
MisterBates Posted August 1, 2007 Share Posted August 1, 2007 After many tries I realized that the AutoIT Regexp doesn't have ending delimiter (/) like in PHP . After removing the two (/) and (/i) in my pattern, the results are right but I don't know whether this action can affect or not I'm not sure I understand "whether this action can affect or not"? Are you trying to recrate a PHP script in AutoIt? Surely the test would be that the AutoIt script does what the PHP used to do ... or have I missed something? [u]MisterBates[/u]_____________________________________________________Suspend/Resume Windows ScreensaverWatchWindows - Window watcher/loggerUDF: Click systray menu/submenu itemsUDF: Outlook Express Folder/Message handling (+ example code)HowTo: Multiple icons in one compiled script Link to comment Share on other sites More sharing options...
Who Posted August 1, 2007 Author Share Posted August 1, 2007 I mean after I deleted the PHP ending delimiters in AutoIT program, the results of AutoIt are equal to PHP 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