Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 463 Bytes

regex examples.md

File metadata and controls

24 lines (20 loc) · 463 Bytes

Remove lines with multiple values

data = re.sub(r'\n\s*"(val1|val2|val3)".*', r'', data)

Remove lines starting with a #

data = re.sub(r'\n.*#.*', r'', data)

Remove a comma

data = re.sub(r',(\n\s*})', r'\1', data)

Add quotes

data = re.sub(r'("default_risk": )([^\n]*)', r'\1"\2"', data)

Remove blank lines

data = re.sub(re.compile(r'\n\s*\n', re.M | re.S), r'\n', data)