brodie28 Posted June 25, 2006 Posted June 25, 2006 I, unfortunatly still suck at StringRegExp. I am getting better, just very very slowly. I am trying to get as much practice as I can in, because it is a very useful and powerful tool. I am writing a program which is going to record all of the different boards on a forum... To do this I need to extract the title of each board on the forum from its source code. Here is an example. Source code: <div id="content"> <div class="head"><h1>Site Suggestions</h1></div> <div id="board_wrap"> The title of the board in this example is obviously "Site Suggestions" But I need a StringRegExp pattern that will extract it for every board. Thanks in advance guys.
Xenobiologist Posted June 25, 2006 Posted June 25, 2006 (edited) HI, try this: $string = '<div id="content"> <div class="head"><h1>Site Suggestions</h1></div><div id="board_wrap">' $found_A = _SRE_Between($string, '<div class="head"><h1>', '</h1></div>', 1) If IsArray($found_A) Then For $i = 0 To UBound($found_A) - 1 MsgBox(0, '', $found_A[$i]) Next Else MsgBox(0, '', $found_A) EndIf Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0] If IsArray($a_Array) Then Return $a_Array EndFunc Only the first (for the pattern) #include<Array.au3> $string = '<div id="content"> <div class="head"><h1>Site Suggestions</h1></div><div id="board_wrap">' $found_A = StringRegExp($string, '(?:<div class="head"><h1>)(.*?)(?:</h1></div>)', 1) _ArrayDisplay($found_A, "") So long, Mega Edited June 25, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
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