eltorro Posted January 12, 2006 Share Posted January 12, 2006 (edited) I'm trying to extract a number following some text using regular expressions#include <Array.au3> ;some text from a webpage $test = "Server: Apache/1.3.33 (Unix) PHP/5.0.4 mod_perl/1.29"&@crlf $test &= "Connection: close"&@crlf $test &= "Content-Type: text/html"&@crlf $test &= @crlf $test &="<HTML><HEAD><TITLE>UPDATEDNS</TITLE></HEAD><BODY>" &@crlf $test &="<!-- DDNS_Response_Code=101 -->" &@crlf $test &="Status Code: <B>101</B><BR>" &@crlf $test &="Successful Update.<BR>" &@crlf msgbox(0,"Test Text",$test) ;find number after "DDNS_Response_Code=" ;find non capturing group and capturing group $pattern ="((?:DDNS_Response_Code=)[0-9]+)" $result = StringRegExp($test,$pattern,1) _ArrayDisplay($result,"Results")The return value is "DDNS_Response_Code=101".Shouldn't it be "101"?By the way I am using beta 101. Kinda weird huh? Edited January 12, 2006 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 12, 2006 Moderators Share Posted January 12, 2006 (edited) $pattern ="((?:DDNS_Response_Code=)([0-9]+))" Edit: And this if you want it to be [1] to return the right option. $pattern ="((DDNS_Response_Code=)([0-9]*))" Edited January 12, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
eltorro Posted January 13, 2006 Author Share Posted January 13, 2006 Thanks for the help. Sorry it took so long to reply back. $pattern = "DDNS_Response_Code=(\d+)" also works but I would rather use grouping. Gotta learn more on regexp. Thanks, eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code 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