• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Python Regex WTF?!

Armitage

Banned
I've used python Regex's before, but always was matching from the beginning of the line. Now I'm trying to find something in the middle of a line and have run into a serious WTF??

In the python interpretor...

>>> import re
>>> ptrn = re.compile("Quick")
>>> x = "The Quick Brown Fox"
>>> ptrn.match(x)

No Match???

If I add a '.*' to the beginning of the pattern: ptrn = re.compile(".*Quick")
I get the match - but I don't want all that crap before it if I use findall or split.
What gives here?
 
More WTF:
If you don't use a compiled regex pattern, it works as expected. For example, the following works:

>>> re.search("Quick", "The Quick Brown Fox")
 
grrr ... match() only looks at the beginning of the string, search() does the whole thing.
It sucks being in a hurry. I'm an idiot :|
 
Back
Top