Not sure if there's a regex to handle comment markers + string apostrophes + transpose apostrophes.
Thought about switching ','.join(lines) to "\n".join, but that seems to create side effects like line continuation issues (in other code, not in this example).
comment_pattern = re.compile(r"(^(?:[^'%]|'[^']*')*)(%.*)$")
gets hung up with single apostrophes.Raw code:
Run code:
Not sure if there's a regex to handle comment markers + string apostrophes + transpose apostrophes.
Thought about switching
','.join(lines)
to"\n".join
, but that seems to create side effects like line continuation issues (in other code, not in this example).