Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Separate the strings
Message
De
26/03/2016 10:52:33
 
 
À
26/03/2016 10:05:47
Lutz Scheffler (En ligne)
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01633712
Message ID:
01633809
Vues:
60
>>>>>Hi Craig,
>>>>>
>>>>>Just lurking on the thread as I have difficult parsing tasks to perform soon.
>>>>>
>>>>>Thanks a lot for the pointer:)
>>>>>
>>>>>Daniel
>>>>
>>>>You may want to look at regular expressions - depends on the task
>>>Hi Grgory - master of the regexp
>>>
>>>consider a string like this messsage. How to to create a pattern
>>>
>>>Anything after the line starting with >>You? IOW from Hi Gregory, but this is not the key information.
>>
>>Lutz, can you give an example - don't see what you mean
>
>Hi Gregory
>
>The message itself is the example :)
>
>Just take this whole text.
>I lake to get alll the lines after the line starting with >>>You (but not this line) as the one and only result
>possibly with just one regexp. With more then on command I have an idea how to do.

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 
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform