Superseded by a larger gist, CodeFenceCleanup.
Here's expand.py
in that other
gist.
License: Like that one, this gist is likewise offered under CC0.
Superseded by a larger gist, CodeFenceCleanup.
Here's expand.py
in that other
gist.
License: Like that one, this gist is likewise offered under CC0.
#!/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) |