newbie - Regular expression help

June Kim junaftnoon at nospamplzyahoo.com
Sun Nov 19 09:09:00 EST 2000


"Satheesh Babu" <vsbabu at erols.com> wrote in message
news:8v8i2a$lmt$1 at bob.news.rcn.net...
> Hi all,
>
> I need to scan a string and replace all occurrences of
> "./" with null. But "../" shouldn't get changed.
>
> Stupid way is to first replace ../ with AbRaCaDaBrA
> and then replace ./ with null and then replace
> AbRaCaDaBrA with ../
>
> There should be a simpler solution.
>

One simpler solution may be,

>>> pat=re.compile(r'[^.](\./)')
>>> pat.sub('',s)


> Anyone, please...
>
> Thx
>
>




More information about the Python-list mailing list