ElOrAnElle Posted June 13, 2011 Share Posted June 13, 2011 Hi,new here, but haven't been able to figure this one out.I have a large amount of text I want to split (into an array ideally). There's no straight string delineating the text but I have a regexp to match where I want to split. I want the array to include all the source text and each new element to start with the matching regular expression. I'm probably missing something very dumb: anyone see fit to set me straight?Thanks! Link to comment Share on other sites More sharing options...
jchd Posted June 13, 2011 Share Posted June 13, 2011 Can you post sample input, pattern, code and expected output so we can at least help you? 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...
Moderators Melba23 Posted June 13, 2011 Moderators Share Posted June 13, 2011 ElOrAnElle, Welcome to the AutoIt forum. Your question is a bit vague. Does this help? #include <Array.au3> $sString = "frad11111fred22222frid33333frod44444frud55555" ; Extract the delimiters $aDelim = StringRegExp($sString, "fr.d", 3) ; Split the string on the delimiters $aParts = StringSplit(StringRegExpReplace($sString, "fr.d", "****"), "****", 3) ; Add the delimter to the start of the part For $i = 0 To UBound($aDelim) - 1 $aParts[$i + 1] = $aDelim[$i] & $aParts[$i + 1] Next ; Set the count $aParts[0] = UBound($aDelim) ; Display the result _ArrayDisplay($aParts) 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...
czardas Posted June 13, 2011 Share Posted June 13, 2011 (edited) I'm not so hot on regexp, but I like the idea of this. It should be simple enough to add delimeters using StringRegExpReplace.EditI just saw the above post. Nice example Melba. Edited June 13, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
ElOrAnElle Posted June 13, 2011 Author Share Posted June 13, 2011 Melba23, I was all set to post some sample code which looks like something the cat threw up compared to yours. but that's done exactly what I wanted. Thanks! I will remember to include the samples first, next time I have a question. jchd thanks for your quick reply, silly of me not to include any source (though at the time all I had was text and a scratched head). And czardas, it's nice code, and I didn't think of just using replace like that. A 'duh' light bulb idea, so simple yet so effective! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 13, 2011 Moderators Share Posted June 13, 2011 ElOrAnElle, Glad I could help. 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...
GEOSoft Posted June 13, 2011 Share Posted June 13, 2011 M23 Been soaring the azure skys again? You've been missed; not by me of course but I'm sure by someone. 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...
Moderators Melba23 Posted June 13, 2011 Moderators Share Posted June 13, 2011 George,Been soaring the azure skys again?If only! Been visiting the in-laws on the other side of the Channel for a while - no internet connection and all their neighbours have password protected WiFi! Slipping the "surly bonds"* again on Wednesday weather permitting. M23* "High Flight" 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...
GEOSoft Posted June 13, 2011 Share Posted June 13, 2011 Ha, there have been a few good pieces of poetry written by Canadian men overseas. Can't forget "In Flanders Fields" We now resume on-topic discussion for those that wish to participate. 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