Regular Expression for pattern substitution

V

Vibha Tripathi

It'd be silly to write the code for it if it already
exists somewhere in the Python re or sre library
module:

I need to find and replace all strings in a text file
from a certain pattern to another pattern.

so for example if I see 'this(\D*)that' anywhere in
the file then I'd like to make is 'that(\D*)this'
where the middle part of the strings remains
unmodified.

Any suggestions?

Peace.
Vibha

PS. How do I avoid getting my email ID web-published
for this mailing list.?



____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
 
D

Devan L

re.replace.

I don't think there's any way to avoid it. Except maybe having an alias
email address or a fake one.
 
G

George Sakkis

Deval L said:
re.replace.

There isn't a re.replace; be careful when you reply to newbies.

Fire up the interpreter and write:
'see that man with this woman holding that dog and this cat'


George
 
D

Devan L

Hrm, thought it had one. Guess it would help if I actually used regular
expression for replacement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top