Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Separate the strings
Message
From
27/03/2016 05:17:05
 
 
To
26/03/2016 14:12:16
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01633712
Message ID:
01633822
Views:
69
>>Try this
>>
function Lutz()
>>
>>	local s
>>	text to s noshow flags 1 pretext 7
>>		some text
>>		>>>You guy
>>		line 1
>>		line 2
>>		...
>>		line nnn
>>	endtext
>>
>>	local regexObj, pattern
>>	regexObj = createobject('VBScript.RegExp')
>>	regexObj.IgnoreCase = .f.
>>	regexObj.Multiline = .f.
>>	regexObj.Global = .f.
>>	
>>	pattern = '^(\x0d\x0a|.)*\x0d\x0a>>>You.*\x0d\x0a((\x0d\x0a|.)*)$'
>>	regexObj.pattern = m.pattern 
>>	
>>	
>>	local matches
>>	matches = m.regexObj.Execute(m.s)
>>	
>>	do case
>>	case !inlist(m.matches.Count, 1)
>>		? 'fail'
>>	otherwise
>>		?matches.item[0].Submatches(1)
>>		
>>	endcase
>>endfunc 
>>
>
>Okay. I try to understand this .....
>
>So far I see a submatch containing all, until followed by the line I'm looking for (out of the hip: what happens if this is the first line?) + linebreak, followed by the rest as submatch
>
>Why do I need the first submatch?
>What does the | infront of the dot in the enumerations?


> what happens if this is the first line?)
It won't work - use pattern below
pattern = '^(.*\x0d\x0a)*>>>You.*\x0d\x0a((\x0d\x0a|.)*)$'
> Why do I need the first submatch?
In fact you need the second submatch - they are zero based

>What does the | infront of the dot in the enumerations?

That is the OR symbol


Alternatively, there's nothing holding you back finding the '>>> You' with or without regex, then taking the rest after the match
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform