Moderators Melba23 Posted February 25, 2013 Moderators Posted February 25, 2013 PhoenixXL,I'm lateBeating you to a Regex has made my day! 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
gcue Posted March 6, 2013 Author Posted March 6, 2013 (edited) sorry to re-open this... i am still missing some matches. i think this would work... so if this is the string $sString = ";<-------------------- begin MustHave --------------------->" & @CRLF & _ "" & @CRLF & _ ";<-------------------- begin PC_Anywhere --------------------->" & @CRLF & _ "" & @CRLF & _ ";<-------------------- begin Window Context Menu --------------------->" & @CRLF & _ "" & @CRLF & _ ";<-------------------- begin Web, File, Folder Notes Links --------------------->" & @CRLF & _ "" & @CRLF & _ "$changelog_all_entries[898] = 'New|PC_Anywhere: option to PC Anywhere remote PCs where available.|0.4.1.7'" & @CRLF & _ "$changelog_all_entries[899] = 'Changed|MustHave: entries automatically sort alphabetically after editing or adding items.|0.4.1.8'" & @CRLF & _ "$changelog_all_entries[900] = 'Changes|MustHave: parent categories do not need to be selected for adding and editing items.|0.4.1.8'" & @CRLF & _ "$changelog_all_entries[898] = 'New|PC Anywhere: option to PC Anywhere remote PCs where available.|0.4.1.9'" & @CRLF & _ "$changelog_all_entries[900] = 'Changes|Window Context Menu: another of gcues little gotchas|0.4.1.10'" & @CRLF & _ "$changelog_all_entries[900] = 'Changes|Web, File, Folder Notes Links: and yet another one - when will it end?|0.4.1.11'" strip out underscores, spaces and comma's from both the search text (begin ....) and where it searches in the changelog entries. thank you!!! Edited March 6, 2013 by gcue
Moderators Melba23 Posted March 6, 2013 Moderators Posted March 6, 2013 gcue, And what have you tried so far that has not worked? 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
gcue Posted March 6, 2013 Author Posted March 6, 2013 this is what i have so far... ; Get list of begin "text" $aBegin = StringRegExp($data, "(?U)begin\s(.*)\s-", 3) ;~ _ArrayDisplay($aBegin) ; Now look for data Local $aFinal[1] = [0] For $i = 0 To UBound($aBegin) - 1 $text = StringReplace($aBegin[$i], " ", "") $text = StringReplace($text, "_", "") $text = StringReplace($text, ",", "") ; Amend underscore and spaces to look for both ;~ $sLine = StringRegExpReplace($aBegin[$i], "[\s|_]", "\[\\s\|_\]") ; Extract lines $aRet = StringRegExpReplace($data, "(?U)" & $text & ":\s(.*)'", "") ; Add to list _ArrayConcatenate($aFinal, $aRet) $aFinal[0] += UBound($aRet) ConsoleWrite($text & @CRLF) for $j = 1 to UBound($aRet)-1 ConsoleWrite($aRet[$j] & @CRLF) Next ConsoleWrite(@CRLF) Next ;~ _ArrayDisplay($aFinal)
Moderators Melba23 Posted March 6, 2013 Moderators Posted March 6, 2013 gcue, This strips the spaces, commas and underscores as you asked: expandcollapse popup#include <Array.au3> $sString = ";<-------------------- begin MustHave --------------------->" & @CRLF & _ "" & @CRLF & _ ";<-------------------- begin PC_Anywhere --------------------->" & @CRLF & _ "" & @CRLF & _ ";<-------------------- begin Window Context Menu --------------------->" & @CRLF & _ "" & @CRLF & _ ";<-------------------- begin Web, File, Folder Notes Links --------------------->" & @CRLF & _ "" & @CRLF & _ "$changelog_all_entries[898] = 'New|PC_Anywhere: option to PC Anywhere remote PCs where available.|0.4.1.7'" & @CRLF & _ "$changelog_all_entries[899] = 'Changed|MustHave: entries automatically sort alphabetically after editing or adding items.|0.4.1.8'" & @CRLF & _ "$changelog_all_entries[900] = 'Changes|MustHave: parent categories do not need to be selected for adding and editing items.|0.4.1.8'" & @CRLF & _ "$changelog_all_entries[898] = 'New|PC Anywhere: option to PC Anywhere remote PCs where available.|0.4.1.9'" & @CRLF & _ "$changelog_all_entries[900] = 'Changes|Window Context Menu: another of gcues little gotchas|0.4.1.10'" & @CRLF & _ "$changelog_all_entries[900] = 'Changes|Web, File, Folder Notes Links: and yet another one - when will it end?|0.4.1.11'" ; Simulate loading the file into an array $aLines = StringSplit($sString, @CRLF, 1) Global $aBegin[1] = [0] For $i = 1 To $aLines[0] ; Is it a "begin" line If StringInStr($aLines[$i], ";<-") Then ; Extract the text $sExtract = StringRegExpReplace($aLines[$i], "(?U)\A.*begin\s(.*)\s-.*\z", "$1") ; Strip spaces, commas and underscores $sExtract = StringReplace(StringReplace(StringStripWS($sExtract, 8), "_", ""), ",", "") ; Add to array $aBegin[0] += 1 ReDim $aBegin[$aBegin[0] + 1] $aBegin[$aBegin[0]] = $sExtract EndIf Next ; Result _ArrayDisplay($aBegin) ; Now look for data Local $aFinal[1] = [0] For $i = 1 To $aLines[0] ; Is it a "changelog" line If StringInStr($aLines[$i], "$changelog") Then ; Extract the section which might match $sExtract = StringRegExpReplace($aLines[$i], "(?U)\A.*\|(.*):.*\z", "$1") ; Strip spaces, commas and underscores $sExtract = StringReplace(StringReplace(StringStripWS($sExtract, 8), "_", ""), ",", "") ; See if we have a match $iIndex = _ArraySearch($aBegin, $sExtract) If $iIndex <> -1 Then ; ; Extract the section which we need $sExtract = StringRegExpReplace($aLines[$i], "(?U)\A.*:\s(.*)'\z", "$1") ; Add to array $aFinal[0] += 1 ReDim $aFinal[$aFinal[0] + 1] $aFinal[$aFinal[0]] = $sExtract EndIf EndIf Next ; And here we are! _ArrayDisplay($aFinal) But does it work as you expected? 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
gcue Posted March 6, 2013 Author Posted March 6, 2013 (edited) hmm not really dealing with the string.. the string was just an example of what the text looked like in the script... your example works wonderfully though.. =) $file = "C:\script.au3" $data = FileRead($file) ; Get list of begin "text" $aBegin = StringRegExp($data, "(?U)begin\s(.*)\s-", 3) haha love the changelog text edits too =) Edited March 6, 2013 by gcue
gcue Posted March 6, 2013 Author Posted March 6, 2013 (edited) ok so here's what im trying to do... im trying to list out all the functions in the script.... they all are bunched up with ;<--- begin FUNCTION then im trying to pull together the descriptions for each of those functions in the change logs so <Function> ---- (any thing found in the changelog regarding that function) -entry1 -entry2 -etc i have around 100 functions that i want to gather descriptions for and also do put together a training manual.. so i figure if this could be automated... that much easier to get this project going... hope that makes sense =) thank you!!! Edited March 6, 2013 by gcue
Moderators Melba23 Posted March 6, 2013 Moderators Posted March 6, 2013 gcue,You need to read the file into an array using _FileReadToArray - not the simple FileRead you are using. I tried to explain that with the "; Simulate loading the file into an array" comment: $file = "C:\script.au3" Global $aLines FileReadToArray($file, $aLines)Now you have the file in a format that the script can use. 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
Moderators Melba23 Posted March 6, 2013 Moderators Posted March 6, 2013 gcue,ok so here's what im trying to do...So after 27 posts you spring yet another suprise. You told me on the previous page:haha nope sorry man - no more "gotchas"and yet here you are again moving the goal-posts in mid-match. I am afraid that is one too many - I am out and extemely annoyed. 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
gcue Posted March 6, 2013 Author Posted March 6, 2013 so sorry Melba - i failed to communicate accurately. like you said, i should have come out and laid out my goal from the getgo. my sincere apologies. at any rate, thank you again for all your help. definitely a learning experience in more than one respect. thanks again
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