TeTube Posted September 27, 2011 Posted September 27, 2011 (edited) Hello people, I wrote some AutoIT script to parse all Strings from a html page into an array.After this, I want to extract strings out of the big string array via StringRegExp. Code: $oIE is my internet explorer handle where to parse the data from$aBodyText is the array where all strings are parsed in.$aProfileNames is the array where the extracted strings should be stored in. While 1 $aBodyText = StringSplit(_IEBodyReadText($oIE), "", 1) If @error = 0 Then ExitLoop TrayTip("Error_Readnames:", "While doing StringSplit", 10) Sleep (10000) WEnd While 1 ;- String Pattern: "w (0-9)(0-9) Profilename" $aProfileNames = StringRegExp($aBodyText[2], " w \d\d (.*)", 3) If @error = 0 Then ExitLoop TrayTip("Error_Readnames:", "While doing StringRegExp", 10) Sleep (10000) WEnd Here is an example of the extracted html body:http://pastebin.com/UBTvpMacThe data I would like to extract starts in 1822. and appears always as w DIGITDIGIT XXXXXXXXXXXXXXX Somehow, when I run this, I get an error in the regular expression part. Edited September 27, 2011 by TeTube
Moderators Melba23 Posted September 27, 2011 Moderators Posted September 27, 2011 TeTube,Welcome to the AutoIt forum. That way of giving us data is not a lot of use - much better to post a string. I think this is what you want, based on what I think is the data I could extract from the dump you linked to:#include <Array.au3> $sText = "Login vor 13 Min.w 16 its_adel 12 BerlinLogin vor 1 Std.w 16 _Paattie 13" $aMatches = StringRegExp($sText, "(?i)(?U)w\x20\d\d\x20(.*)\x20", 3) _ArrayDisplay($aMatches)Note I used the \xDD format to define a space and not a literal {SPACE}. SRE Explanation:(?i) - Case insensitive (in case you find a W) (?U) - look for the smallest matches (try it without this and see what you get!) w\x20\d\d\x20 - look for "w " followed by 2 digits and then another " " (.*) - capture everything up until \x20 - the next " "Does it work for you? If not post a string holding the data so we can work with it more easily. 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
TeTube Posted September 27, 2011 Author Posted September 27, 2011 (edited) Thanks for the fast reply.Well, this is exactly what I was looking for. The strings gonna look like: "w 21 OmgItsMe spoagdnoisdg owegpsogaüpgüsgrjopwog päpgnwpejgpweg w 18 YeahItsme sigosgnsdpgnsogn afoknsog oafodsigosö oghs w 18 soPro " But actually I m no sure if I can just pass the whole string array from the stringsplit function into the StringRegExp?Like I have a working regular expression, but the data I parse isnt working? °_° Edited September 27, 2011 by TeTube
Moderators Melba23 Posted September 27, 2011 Moderators Posted September 27, 2011 TeTube,I m no sure if I can just pass the whole string array from the stringsplit function into the StringRegExpThere is no need to use StringSplit at all - just pass the whole string into the SRE as I did above. Sorry, I should have told you specifically, but I thought the example code was clear enough. SREs work (as their name suggests ) on strings, not arrays. 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
TeTube Posted September 27, 2011 Author Posted September 27, 2011 (edited) Again, thanks I just parsed the HTML body directly into the SRE. In each Step, I add the extracted Data into a global array. After, it parsed all the data I wanted into a global array, this steps appears tto be correct (_ArrayDisplay showed me in the end a correct array) But now, the rest of my program doesnt work anymore (the parts which use the global array) xD? Could it be the parsed string via SRE changed? Edited September 27, 2011 by TeTube
Moderators Melba23 Posted September 27, 2011 Moderators Posted September 27, 2011 TeTube,There is nothing to stop you using StringSplit to create an array to use in the rest of your script - you just do not need it for the SRE part. 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
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