ATR Posted June 24, 2013 Posted June 24, 2013 Hello, I have a small regexp problem... Many hours that I search solution, but I don't find I have a string localisationBlock....many text......<p><strong>Agence CFI Mâcon</strong><br>6 grande rue de la Coupée<br>71850 Charnay lès Mâcon</p> and <strong> and </strong> are not always present I have my regexp : '(?s)localisationBlock.*?(?:<p><strong>|<p>)(.*?(?:</strong>)?)</p>.*?/div' Thanks in advance
Xenobiologist Posted June 25, 2013 Posted June 25, 2013 Maybe it would be easier to adress the containing elemt in your webpage by name or id and then just read the innerhtml instead of the text with all the tags. 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
ATR Posted June 25, 2013 Author Posted June 25, 2013 (edited) In fact I already use _IETagNameGetCollection() function. $Donnees = _IETagNameGetCollection($IE, "li") For $Donnee In $Donnees If StringInStr($Donnee.classname, "visitCard withVisual sc") Then $Adresse = StringRegExp($Donnee.outerhtml, '(?s)localisationBlock.*?(?:<p><strong>|<p>)(.*?(?:</strong>)?)</p>.*?/div', 1) If @error = 0 Then consolewrite($Adresse[0] & @crlf) EndIf EndIf Next Edited June 25, 2013 by ATR
FireFox Posted June 25, 2013 Posted June 25, 2013 (edited) Hi, You are not explaining what you want to get with your regular expression... Edit: Please provide an example of the desired output in all cases. (with or without the strong tags as you said) Br, FireFox. Edited June 25, 2013 by FireFox
ATR Posted June 25, 2013 Author Posted June 25, 2013 <div class="localisationBlock"> <p><strong>Agence CFI Mâcon</strong><br>6 grande rue de la Coupée<br>71850 Charnay lès Mâcon</p> <ul> </div> And I want : Agence CFI Mâcon 6 grande rue de la Coupée 71850 Charnay lès Mâcon Best regards
FireFox Posted June 25, 2013 Posted June 25, 2013 #include <Array.au3> $s = FileRead("t.txt") $a = StringRegExp($s, "(?m)>(.*?)<", 3) _ArrayDisplay($a)
mikell Posted June 25, 2013 Posted June 25, 2013 $txt = ' <div class="localisationBlock">' &@crlf& _ ' <p><strong>Agence CFI Mâcon</strong><br>6 grande rue de la Coupée<br>71850 Charnay lès Mâcon</p>' &@crlf& _ ' <ul>' &@crlf& _ ' </div>' msgbox(0,"", $txt) $txt = StringRegExpReplace($txt, '(?s)(<.*?>)+', @crlf) $txt = StringStripWS(StringReplace($txt, ' ', " "), 3) msgbox(0,"", $txt)
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