erifash Posted April 30, 2005 Share Posted April 30, 2005 After searching on the forums and help file I have created a string parser that only uses two lines of code. I made it because I needed to parse some html for a web-spider i'm making that harvests links and such...Okay:$sz_str = string to parse$sz_before = text that comes before the info you want$sz_after = text that comes after the info you wantFunc _Parse($sz_str, $sz_before, $sz_after) Local $sz_sp1 = StringSplit($sz_str, $sz_before, 1), $sz_sp2 = StringSplit($sz_sp1[$sz_sp1[0]], $sz_after, 1) Return $sz_sp2[1] EndFuncAny comments/questions are greatly appreciated! My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Insolence Posted April 30, 2005 Share Posted April 30, 2005 Eh, regexp is probably a bit faster. If this was introduced before, it would've been much more appriciated Good idea, bad timing. "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
erifash Posted April 30, 2005 Author Share Posted April 30, 2005 (edited) Good idea, bad timing.<{POST_SNAPBACK}>Thanks anyway. Edited April 30, 2005 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Insolence Posted April 30, 2005 Share Posted April 30, 2005 Happens to the best of us "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
erifash Posted April 30, 2005 Author Share Posted April 30, 2005 Here's the example: (it actually works!) $url = "http://www.google.com" $file = "html.txt" If not _INetActive() Then Exit InetGet($url, $file) $html = FileRead($file, FileGetSize($file)) FileDelete($file) MsgBox(0, "_Parse() - " & $url, _Parse($html, "Google - Searching ", " web pages")) Func _Parse($sz_str, $sz_before, $sz_after) Local $sz_sp1 = StringSplit($sz_str, $sz_before, 1), $sz_sp2 = StringSplit($sz_sp1[$sz_sp1[0]], $sz_after, 1) Return $sz_sp2[1] EndFunc Func _INetActive() If @IPAddress1 <> "127.0.0.1" Then Return 1 Return 0 EndFunc My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
steveR Posted April 30, 2005 Share Posted April 30, 2005 Could be useful to people who don't know regexp. But if someone doesn't know regexp, they are missing out on a powerful tool. AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
layer Posted April 30, 2005 Share Posted April 30, 2005 I just made a script THIS morning... It count's the number of links on a webpage. But I want to write one in C++ now FootbaG Link to comment Share on other sites More sharing options...
randallc Posted May 1, 2005 Share Posted May 1, 2005 OK, so can you enlighten me on "regexp"; how are you using this? - part of Autoit or accessed by it? Thanks, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Insolence Posted May 1, 2005 Share Posted May 1, 2005 It's in the beta, look in the help file for 'StringRegExp' "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. 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