Allow2010 Posted March 24, 2012 Share Posted March 24, 2012 hi, i need to find in html source the selected value from this <select id="uiViewDownTime" name="down_time_value" onchange="" size="1"> <option value="15" >15 Minuten</option> <option value="30" selected="selected">30 Minuten</option> <option value="45" >45 Minuten</option> <option value="60" >60 Minuten</option> <option value="90" >90 Minuten</option> <option value="120" > 2 Stunden</option> <option value="180" > 3 Stunden</option> <option value="240" > 4 Stunden</option> <option value="300" > 5 Stunden</option> <option value="360" > 6 Stunden</option> <option value="480" > 8 Stunden</option> <option value="600" >10 Stunden</option> <option value="720" >12 Stunden</option> <option value="900" >15 Stunden</option> <option value="1080" >18 Stunden</option> <option value="1260" >21 Stunden</option> </select> I have this php code which does the trick, preg_match('@name="down_time_value".*?<option value="(\d+)"[^>]+?selected.*?</select>@s', $output, $matches); but i can not get it working in autoit with StringRegExp. Can some RegExp professional please help me out (and if possible even explain it, so i can learn a bit:-)) Thanks in advance! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2012 Moderators Share Posted March 24, 2012 Allow2010,Certainly not a "RegExp professional", but this works for me: $sHTML = '<select id="uiViewDownTime" name="down_time_value" onchange="" size="1">' & @CRLF & _ '<option value="15" >15 Minuten</option>' & @CRLF & _ '' & @CRLF & _ '<option value="30" selected="selected">30 Minuten</option>' & @CRLF & _ '<option value="45" >45 Minuten</option>' & @CRLF & _ '<option value="60" >60 Minuten</option>' & @CRLF & _ '<option value="90" >90 Minuten</option>' & @CRLF & _ '<option value="120" > 2 Stunden</option>' & @CRLF & _ '<option value="180" > 3 Stunden</option>' & @CRLF & _ '<option value="240" > 4 Stunden</option>' & @CRLF & _ '' & @CRLF & _ '<option value="300" > 5 Stunden</option>' & @CRLF & _ '<option value="360" > 6 Stunden</option>' & @CRLF & _ '<option value="480" > 8 Stunden</option>' $aRet = StringRegExp($sHTML, '(d+)"ssel', 3) MsgBox(0, "Result", $aRet[0])Translation:(d+) - Capture a string of digits "ssel - followed by a double quote, a space, and the string "sel" 3 - Return an array of what was foundM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Allow2010 Posted March 24, 2012 Author Share Posted March 24, 2012 Thank you for your help.... it work fine, but i should have mentioned that the above html is only part of a bigger html page and there may be other lines that contain "selected" thats why there is a bit more regex vodoo in the original line:-) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2012 Moderators Share Posted March 24, 2012 Allow2010,but i should have mentioned that the above html is only part of a bigger html page and there may be other lines that contain "selected"Quite so - then I would not have wasted my time posting the above M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Allow2010 Posted March 24, 2012 Author Share Posted March 24, 2012 my aplogies... Link to comment Share on other sites More sharing options...
GEOSoft Posted March 24, 2012 Share Posted March 24, 2012 change m23s expression to use the flag 4 instead of 3 and see if that gives you what you want. it should be a php compatable array of arrays.Using the toolkit in my signature should allow you to load the page on the 'load web page' as html and test it in there. just make sure you select the 4 flag. you could even run a couple of tests using each of the flags to get used to how they work in pcre.tip; since the help file was never finished, hover over any of the controls and look at the status bar to see what they do. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Allow2010 Posted March 24, 2012 Author Share Posted March 24, 2012 Thanks, for the infos, i will try... Link to comment Share on other sites More sharing options...
Allow2010 Posted March 26, 2012 Author Share Posted March 26, 2012 (edited) I got all my regex working fine so far, but the one above still drives me mad... Can anyone tell me what the @ at he beginning and the "@s" in this regex means? I beleive it is something only valid in php... preg_match('@name="down_time_value".*?<option value="(d+)"[^>]+?selected.*?</select>@s', $output, $matches); Help please, i did a lot of reading, just can't find out this one:-) Edited March 26, 2012 by Allow2010 Link to comment Share on other sites More sharing options...
jchd Posted March 26, 2012 Share Posted March 26, 2012 Lookup a php tutorial. My wild guess is that @name and @s are variable interpolation (get replaced by variables values at runtime. But I've been proved wild-guessing wrong before, so have your salt handy. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Allow2010 Posted March 27, 2012 Author Share Posted March 27, 2012 thanks...have reading up several manuals...none mentions @ :-( Link to comment Share on other sites More sharing options...
GEOSoft Posted March 27, 2012 Share Posted March 27, 2012 you will probably have more luck looking for that symbol in a php manual.in php it means 'suppress errors'why it would be used in a regex beats me though.There is a brief description hereor try this google results page George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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