steve8tch Posted December 12, 2009 Posted December 12, 2009 I have the following dataasfafZCZwtraphuplkjka..etcI would like to pick up the sectionsasfafZCZwtraphuplkjketcObviously the real data is more complicated and varied.... Somehow I need to match the "a". The "a" needs to be included as the first entry in each section captured and the data I require includes everything up to the beginning of the next "a"There is a workaround , where I can do a StringRegExpReplace($str,"a","@@a") and then match between the "a" and the "@@", but my feeling is that this can be achieved with the correct pattern.Has Anyone any thoughts ?Thanks.Steve
Authenticity Posted December 12, 2009 Posted December 12, 2009 Local $sText = "asfaf" & @CRLF & "ZCZ" & @CRLF & "wtr" & @CRLF & "aphup" & @CRLF & "lkjk" & @CRLF & "a..etc" Local $aMatch = StringRegExp($sText, "(?s)(?m)^a.*?(?=^a|\z)", 3) If IsArray($aMatch) Then For $i = 0 To UBound($aMatch)-1 ConsoleWrite($i & ":" & @CRLF & $aMatch[$i] & @CRLF) Next EndIf
steve8tch Posted December 12, 2009 Author Posted December 12, 2009 Well done, and thanks. I have adapted for my example and it works well. This has been a great learning for me. I never new about the ?= "look ahead" option. I can't see it documented in our help file (although now I have looked further it is on the online PCRE section ) Thanks again. Steve
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