Matching at the End of a String : Sub : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Sub »

 

Matching at the End of a String


import re


s = '10NORTH MAIN ROAD
s.replace('ROAD', 'RD.')                  
s = '10NORTH BROAD ROAD
s.replace('ROAD', 'RD.')                       
s[:-4+ s[-4:].replace('ROAD', 'RD.')        
import re                                       

re.sub('ROAD$', 'RD.', s)



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Regular Expressions
» Sub