ignore special characters in python regex
astan.chee at al.com.au
Tue Jul 21 08:59:16 CEST 2009
I think the re.escape did the trick.
to answer your questions:
By "ignore" i meant instead of using non-alphanumeric characters that
have special significance in regular expression (e.g. [|\]) and treat
them as normal strings (i.e preceded by \), but since I don't know all
the characters in regular expression that have special significance, I
don't know which ones to add a '\' infront of.
John Machin wrote:
> On Jul 21, 3:02 pm, Astan Chee <astan.c... at al.com.au> wrote:
>> I'm reading text from a file (per line) and I want to do a regex using
>> these lines but I want the regex to ignore any special characters and
>> treat them like normal strings.
>> Is there a regex function that can do this?
> It would help if you were to say
> (1) what "ignore ... characters" means -- pretend they don't exist?
> (2) what are "special chararacters" -- non-alphanumeric?
> (3) what "treat them like normal strings" means
> (4) how you expect these special characters to be (a) ignored and (b)
> "treated like normal strings" /at the same time/.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list