re.sub substitutes the leftmost, nonoverlapping occurrences of a pattern with a given replacement : Sub : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Sub »

 

re.sub substitutes the leftmost, nonoverlapping occurrences of a pattern with a given replacement


import re

pat = '{name}'
text = 'Dear {name}'
re.sub(pat, 'Mr. Gumby', text)



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Regular Expressions
» Sub