regexp substitution - a lot of work!

Lukas Holcik xholcik1 at fi.muni.cz
Thu Jun 17 08:30:29 EDT 2004


Is it really that easy? Now I see Python is simply the best:)))!

I just didn't know, how to use groups in a different way than 
MatchObject.group(..). You already answered that, thanks!:)

---------------------------------------_.)--
|  Lukas Holcik (xholcik1 at fi.muni.cz)  (\=)*
----------------------------------------''--

On Thu, 17 Jun 2004, Duncan Booth wrote:

> Lukas Holcik <xholcik1 at fi.muni.cz> wrote in
> news:Pine.LNX.4.60.0406161824510.15043 at nymfe30.fi.muni.cz:
>
>> Yes, sorry, I was in such a hurry I didn't found it in the
>> documentation, but when I want to use a lot of very different
>> expressions using a lot of different grouping, which would be easy to
>> implement using s/(..)/x\1x/ then it is quite problematic having to
>> use re.sub(), isn't it?
>>
>
> I don't understand your point. The Python equivalent is:
>
>   re.sub('(..)', r'x\1x', s)
>
> or using a precompiled pattern:
>
>  pat.sub(r'x\1x', s)
>



More information about the Python-list mailing list