I need to use a regex will determine if a single line of python code contains an illegal char
‘$’. But its allowed to appear in a comment or as part of a string.
Meaning:
"legal char $" illegal $ #legal $
The above line should fail because it has a $ that isn’t part of a string or a comment.
If I remove it, and get
"legal char $" legal #legal $
This line should pass.
Illegal: Check for a
.*$.*#?after creating a temporary string by using re.sub to replace \”.*?\” in the line with an empty string.Legal: not Illegal 🙂 or
[^$]*#?