I can do it in sed...

Kotlin Sam xavier_onasis at hotmail.com
Thu Mar 17 18:37:11 EST 2005


Thanks to everyone who answered my two questions. I have only submitted 
questions twice, and on both occasions the solutions were excellent, 
and, I'm emarrassed to say, much simpler than I thought they would be.

My next goal is to be able to help someone they way y'all have helped me.

Thanks again,
Lance

Kent Johnson wrote:
> Kotlin Sam wrote:
> 
>>     Also, I frequently use something like s/^[A-Z]/~&/ to pre-pend a 
>> tilde or some other string to the beginning of the matched string. I 
>> know how to find the matched string, but I don't know how to change 
>> the beginning of it while still keeping the matched part.
> 
> 
> Something like
> re.sub(r'^([A-Z])', r'~\1', target)
> should do it.
> 
> Kent




More information about the Python-list mailing list