RE module question

aditya shukla adityashukla1983 at gmail.com
Fri Oct 3 02:59:18 EDT 2008


Hello folks :

i have a string "-bin-ulockmgr_server:0.99[&&NHX:C=0.195.0]" from which i
want to delete [&&NHX:C=0.195.0] .
I wrote a regular expression for [&&NHX:C=0.195.0] as
\[&&(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.)+\d\]

now when i do

p = re.compile('\[&&(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.)+\d\]')
m =p.search("-bin-ulockmgr_server:0.99[&&NHX:C=0.195.0]")
print m
<_sre.SRE_Match object at 0x01314EE8>
>>> print m.group()
[&&NHX:C=0.195.0]

So i guess i am able to find the substring , my question is how can i delete
this substring from the original string? ie
-bin-ulockmgr_server:0.99 should be my output.

thanks

Aditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081003/7bda0108/attachment.html>


More information about the Python-list mailing list