[Tutor] Advanced String Search using operators AND, OR etc..

Kent Johnson kent37 at tds.net
Mon May 4 22:32:10 CEST 2009


On Mon, May 4, 2009 at 12:38 PM, vince spicer <vinces1979 at gmail.com> wrote:
> 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()

This won't match "approved FDA" which may be desired. It also quickly
gets complicated as the search expressions get more complex. Regex
would also have a hard time with something like
"FDA" AND NOT "approved"

Kent


More information about the Tutor mailing list