regex multiple patterns in order

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Jan 20 11:16:36 EST 2014


On 20/01/2014 16:04, Neil Cerutti wrote:
> On 2014-01-20, Roy Smith <roy at panix.com> wrote:
>> In article
>> <mailman.5748.1390216721.18130.python-list at python.org>, Ben
>> Finney <ben+python at benfinney.id.au> wrote:
>>> Be aware that regex is not the solution to all parsing
>>> problems; for many parsing problems it is an attractive but
>>> inappropriate tool. You may need to construct a more specific
>>> parser for your needs. Even if it's possible with regex, the
>>> resulting pattern may be so complex that it's better to write
>>> it out more explicitly.
>>
>> Oh, posh.
>>
>> You are correct; regex is not the solution to all parsing
>> problems, but it is a powerful tool which people should be
>> encouraged to learn.  For some problems, it is indeed the
>> correct tool, and this seems like one of them.  Discouraging
>> people from learning about regexes is an educational
>> anti-pattern which I see distressingly often on this newsgroup.
>
> I use regular expressions regularly, for example, when editing
> text with gvim. But when I want to use them in Python I have to
> contend with the re module. I've never become comfortable with
> it.
>

You don't have to, there's always the "new" regex module that's been on 
pypi for years.  Or are you saying that you'd like to use regex but 
other influences that are outside of your sphere of control prevent you 
from doing so?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list