Answers for "Replace string using regex"

0

Replace string using regex

import re
line = re.sub(r"</?\[\d+>", "", line)
Posted by: Guest on September-06-2021
0

Replace string using regex

line = re.sub(r"""
  (?x) # Use free-spacing mode.
  <    # Match a literal '<'
  /?   # Optionally match a '/'
  \[   # Match a literal '['
  \d+  # Match one or more digits
  >    # Match a literal '>'
  """, "", line)
Posted by: Guest on September-06-2021

Code answers related to "Replace string using regex"

Browse Popular Code Answers by Language