“Przykłady Python Re.Sub” Kod odpowiedzi

Przykłady Python Re.Sub

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
DreamCoder

Przykłady Python Re.Sub

result = re.sub("(\d+) (\w+)", r"\2 \1")
result = re.sub("(?<number>\d+) (?<word>\w+)", r"\g<word> \g<number>")
DreamCoder

Odpowiedzi podobne do “Przykłady Python Re.Sub”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu