Input: /* ABCD X 1111 */ /* Comment 1111: [[reason for comment]] */
Output: /* ABCD X 1111 # [[reason for comment]] */
Regex used: regex = (?:[\/*]+\sPRQA[\s\w\,]*)(\*\/\s*\/\*\Comment[\w\,]+:)+(?:\s\[\[.*\/$)
How to use the above regex to replace the matched group with '#' in a file with multiple occurrences?
I tried with re.sub(regex, '#\1', file.read(), re.MULTILINE), but this will append # to the matched group.
Is there a direct way to do this instead of iterating line by line and then replacing?