Newbie RE question
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Fri Sep 22 15:44:57 EDT 2006
T:
> I meant to say: Search for any character in r'/\:*?"<>|' in a string
You don't need a RE to solve such problem. There are many ways to solve
it, this is one of the simpler (Python 2.4+):
>>> chars = set(r'/\:*?"<>|')
>>> s1 = "is this a sample string?"
>>> bool( set(s1) & chars )
True
>>> s2 = "this is a sample"
>>> set(s2).intersection(r'/\:*?"<>|')
set([])
Bye,
bearophile
More information about the Python-list
mailing list