Python re.sub() Method
The re.sub() method replaces matches with a replacement
string.
Syntax
re.sub(pattern, repl, string, count=0)
Parameters
| Parameter | Description |
|---|---|
pattern |
Required. The pattern to match. |
repl |
Required. The replacement string. |
string |
Required. The string to search. |
count |
Optional. Max replacements (0 = all). |
Return Value
The modified string.
Example
Output
Click Run to execute your code
Enjoying these tutorials?