Matching Whole Words : Sub : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Sub »

 

Matching Whole Words


import re

s = '10BROAD
print re.sub('ROAD$', 'RD.', s
print re.sub('\bROAD$', 'RD.', s)              
print re.sub(r'bROAD$', 'RD.', s)                   
s = '10BROAD ROAD APT. 3
print re.sub(r'bROAD$', 'RD.', s)                  
print re.sub(r'bROADb', 'RD.', s)



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Regular Expressions
» Sub