Peaser
Peaser

Reputation: 575

Regex not working normally in python

I have this pattern: "(\?(.+?))\b". In python, what should happen, is findall should return ("?var", "var") if i run it on the string: "some text ?var etc".

It works normally elsewhere, here's a regexr for proof.

In python, re's findall returns an empty list. Why is that?

Upvotes: 1

Views: 896

Answers (1)

hwnd
hwnd

Reputation: 70750

You're not using raw string notation:

>>> import re
>>> re.findall(r'(\?(.+?))\b', 'some text ?var etc')
[('?var', 'var')]

Upvotes: 2

Related Questions