[Tutor] Advanced String Search using operators AND, OR etc..
spir
denis.spir at free.fr
Mon May 4 21:18:24 CEST 2009
Le Mon, 4 May 2009 10:38:31 -0600,
vince spicer <vinces1979 at gmail.com> s'exprima ainsi:
> Advanced Strings searches are Regex via re module.
>
> EX:
>
> import re
>
> m = re.compile("(FDA.*?(approved|supported)|Ben[^\s])*")
>
> if m.search(Text):
> print m.search(Text).group()
>
>
> Vince
This is not at all what the origial poster looks for, I guess (or maybe it didn't understand?). Regex can only match one individual sample of request expressed in a logical form with AND and OR clauses.
What he wants is a module able to decode and perform logical searches. It can certainly be built on top of regex, with a layer that:
* decodes logical requests
* performs "sub-matches" for items in the request
* then builds unions (OR) or intersections (AND) of results
I do not know of anything like that for python. But it would be a nice project ;-)
Denis
------
la vita e estrany
More information about the Tutor
mailing list