Regular Expressions 101

Community Patterns

There does not seem to be anything here

Community Library Entry

1

Regular Expression
Python

r"
(^[\t\s]*)(forgot: "to",)(?!\n[\t\s]*insert: "something",)
"
m

Description

Finds a line and appends the replacement below it. Tries to preserve indentation (tabs or spaces) and to avoid duplicate replacements.

I used it in Sublime Text to batch edit several instances of a JS config object across several files.

Submitted by anonymous - 9 years ago