I still have a LOT of perl in use simply because of my hatred of python's regular expressions and I suspect that I'm not the only one...
I still have a LOT of perl in use simply because of my hatred of python's regular expressions and I suspect that I'm not the only one...
Not much of a condolence if you're screen scraping, but still.
I think the first hint that Python wasn't developed with RegEx users in mind would be that in the 700 Page "Learning Python, 3rd Edition" - Regular expressions aren't even mentioned in the Index.
I can see that as a reason for preferring perl's syntax, but I just don't understand hating python's regex, which is what my question was about.
A replacement on python looks like this...
foo = re.compile("<") bar = foo.replace(">", bar)
this works, but it just feels less awkward to me than
$bar = s/</>/
>>> re.sub("<", "<", "something < other")
'something < other'
which seems much more readable and consistent to me than s/a/b, though the s/ syntax is great for vim users like me.I don't think this has as much to do with your programming knowledge as your python knowledge?
Heheheh, boy would that get some bees in some bonnets on the Python dev ML. :)
http://dalkescientific.com/Python/python4ply-tutorial.html#p...
He presented it at PyCon a couple years ago, response seemed to be "that's cool".
Thanks for pointing out my error, and getting me to read the actual code instead of speculating. :)
In Python, much string manipulation is done with builtins (especially string methods) and library functions. The latter work especially well when you target a specific domain (such as HTML) and will often be implemented in regexps. Writing one's own regexps are for when you actually need a small custom state machine. Many problems are too small or too large to justify the effort.