[Tutor] Does it helps to learn "Regular Expressions" or ...
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Mon Oct 30 13:28:54 CET 2006
> Is it useful to know re module and its functions..??
HI Asrarahmed,
Yes. Most people find them to be invaluable in their day-to-day work.
The problem is that they're powerful enough that they look like an
all-in-one tool: it's tempting to use them, even when they are the wrong
tool for the job. *grin* So at least know about regular expressions,
enough to know when and when not to use them.
You might want to look at the Regex HOWTO:
http://www.amk.ca/python/howto/regex/
to get more familiar with regular expressions.
> Or the string module has enough utilities to accomplish string
> manipulation..!!!
For simple things, I'd stick with the methods in strings. For other
complicated tasks, regular expressions may be the right tool. But for
anything that deals with structure (i.e. HTML, XML, JSON), using a real
parser for that language is more appropriate. (Those parsers will usually
be built on top of regular expressions, to hide some ugliness from you.)
Concretely, if anyone asks you to if they can use regular expressions to
parse XML, try to convince them to look into the ElementTree library
first.
Good luck!
More information about the Tutor
mailing list