Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python re.sub Examples

result = re.sub('abc',  '',    input)           # Delete pattern abc
result = re.sub('abc',  'def', input)           # Replace pattern abc -> def
result = re.sub(r's+', ' ',   input)           # Eliminate duplicate whitespaces using wildcards
result = re.sub('abc(def)ghi', r'1', input)    # Replace a string with a part of itself
Source by lzone.de #
 
PREVIOUS NEXT
Tagged: #Python #Examples
ADD COMMENT
Topic
Name
8+3 =