Discuss Simple python regex doubt in the Python Programming forum on Dev Shed. Simple python regex doubt Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
Posts: 404
Time spent in forums: 1 Week 5 h 17 m 55 sec
Reputation Power: 65
Quote:
Originally Posted by prodigyaj
Can you please explain in a couple of sentences why my code is not right and how is this piece of code u gave works?
Let the docs speak: “Note that even in MULTILINE mode, re.match() will only match at the beginning of the string and not at the beginning of each line.”
http://docs.python.org/3/library/re.html
__________________
My armada: openSUSE 12.3 (home desktop, laptop, work desktop), Ubuntu 12.04 LTS (mini laptop), Debian GNU/Linux 7.0 (server), Mythbuntu 12.04 LTS (HTPC), Bodhi Linux 2.0 & Windows 7 Ultimate (test desktop), FreeBSD 9.1 (test server)
Posts: 404
Time spent in forums: 1 Week 5 h 17 m 55 sec
Reputation Power: 65
I have to admit I didn’t even read very thoroughly the regex in question. When first I stumbled into this strange feature of Python’s .match() method – one I still quite can’t understand – I decided always to use .search() since it makes much more sense.