Artem Artem - 1 year ago 68
Python Question

Why python re module does not work with @?

In the following example shows weird problem: Python pattern does not work.

import re
data = r'blah blah @Component blah blah'
m = re.match(r'\@Component', data)
print m

It would print out:


What did I miss here?

Answer Source

You need to use instead, and @ has no special meaning so you do not need to escape it.

>>>'@Component', data).group()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download