Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
code fence cleanup - finding broken code fences
#!/usr/bin/env python3
"""Expand (what's intended to be) a T-SQL expression for searching."""
def expand(text, pattern, replacement, min_count, max_count):
"""Expands \n and a single replacement with repetitions."""
for count in range(min_count, max_count + 1):
print(text.replace(pattern, replacement * count)
.replace(r'\n', "' + CHAR(10) + '")
.replace(r'\N', "' + CHAR(13) + CHAR(10) + '"))
if __name__ == '__main__':
expand(text=r"OR ph.Text LIKE '%\n```{}[^a-z\N]%'",
pattern=r'{}',
replacement=r'[^\N]',
min_count=0,
max_count=8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.