Regular expression issue

Ashok Prabhu ashokprabhuv at gmail.com
Thu Feb 25 08:01:58 CET 2010


Hi,

The following is a sample of my problem. I get input from user and
store it in variable 'b'. I want to match the user input with the
contents of another variable 'a'. However I m not able to get the
exact match. Could someone help?

>>> print a
c
c+

>>> b
'c+'
>>> re.search(b,a).group()
'c'

In the above example I want re to find the string 'c+' instead of 'c'.
I want a solution without escaping the '+' symbol with backslash
because it is given by the user.

Thanks,
~Ashok.



More information about the Python-list mailing list