Searching and Replacing with sub() [and subn()] : Sub : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Sub »

 

Searching and Replacing with sub() [and subn()]


import re

re.sub('X''Mr. Smith', 'attn: XnnDear X,n')
re.subn('X''Mr. Smith', 'attn: XnnDear X,n')
print re.sub('X''Mr. Smith', 'attn: XnnDear X,n')
re.sub('[ae]', 'X''abcdef')
re.subn('[ae]', 'X''abcdef')

# Splitting (on Delimiting Patternwith split()
re.split(':''str1:str2:str3')



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Regular Expressions
» Sub