re.sub do not replace portion of match
Is there a way to flag re.sub not to replace a portion of the string?
I have a very long string that I want to add two new line's to rather
than one, but keep the value X:
string = "test........X.\n.today" <-- note X is a value
string = re.sub("test........X.\n.","test........X.\n\n.", string)
This just replaces X with the replacement string.
Re: re.sub do not replace portion of match
I did look at that, but it was kinda greek to me. Thanks for pulling
out the part I was looking for that should do the trick.
> > Backreferences, such as \6, are replaced with the substring matched by
> > group 6 in the pattern.
|All times are GMT. The time now is 07:35 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.