rich2323 Posted January 13, 2012 Share Posted January 13, 2012 (edited) Could anyone give me a hand with Stringregex I just cant rap my head around it looking at the examples online. Here is the string I need to evaluate: currently: ----------------------------------- Buttonman--A on since: 2012-01-12 15:19:55 Pacific Liber--A on since: 2012-01-12 17:50:48 Pacific Riverden--A on since: 2012-01-12 20:14:17 Pacific Jooby--A on since: 2012-01-12 20:14:18 Pacific rich2323--A on since: 2012-01-12 20:17:16 Pacific I want to retrieve each name before "on since" for each line and disregard the date/time that follows This is what I have so far, but I think I am barking up the wrong tree..as i can get either the first name or I can get all but the first name. This will give me the first name Local $aArray = _StringBetween($howmanywho, '-----------------------------------', 'on since:') _ArrayDisplay($aArray, 'Default Search') This will give me all but the first name Local $aArray1 = _StringBetween($howmanywho, 'Pacific', 'on since:') _ArrayDisplay($aArray1, 'Default Search') The names do change, and they don't always have "--A" following them. Sometimes there will be 3 names in the list sometimes there will only be one. Any suggestions to retrieve all the names? Thanks, Rich Edited January 13, 2012 by rich2323 Link to comment Share on other sites More sharing options...
GEOSoft Posted January 13, 2012 Share Posted January 13, 2012 (edited) #Include<Array.au3>;; For dosplay purposes only Local $sInput = "Buttonman--A on since: 2012-01-12 15:19:55 Pacific" & @CRLF $sInput &= "Liber--A on since: 2012-01-12 17:50:48 Pacific" & @CRLF $sInput &= "Riverden--A on since: 2012-01-12 20:14:17 Pacific" & @CRLF $sInput &= "Jooby--A on since: 2012-01-12 20:14:18 Pacific" & @CRLF $sInput &= "rich2323--A on since: 2012-01-12 20:17:16 Pacific" Local $aNames = StringRegExp($sInput, "(?i)(?m:^)(.+?)s*onssince", 3) If Not @Error Then _ArrayDisplay($aNames) EndIfIf you don't want to match the -A when it does appear then change the expression to$aNames = StringRegExp($sInput, "(?i)(?m:^)(.+?)s*(?:-|A)*s*onssince", 3) Edited January 13, 2012 by GEOSoft 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...
rich2323 Posted January 13, 2012 Author Share Posted January 13, 2012 Works perfect, thank you!!!....now I can dissect it and try and understand it. Must appropriated! Rich2323 Link to comment Share on other sites More sharing options...
GEOSoft Posted January 13, 2012 Share Posted January 13, 2012 Just look in the help file. That one doesn't need much effort to dissect (?i) = case non-sensitive ;; Not required if you are careful (?m:^) = match at the beginning of a line. (.+?) = match and capture anything (non-greedy) s* = match spaces if they exist (?:-|A)* = Match but don't capture hyphens or A if they exist. s* = same as above onssince = "on" followed by a space followed by "since" must exist but it won't be captured. 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