I would like to look for lines that do not begin with a pound sign (#) indentation.
I am currently using regex ^\s*([^\s#].*) With multi-line option.
My problem is that it works great on uncommented lines.
In commented out lines, the regex engine performs backtracking because of \s* completely from the comment mark to the beginning of the line, which can sometimes lead to 40 or 50 return steps.
The regex works fine with python code. This is simply not very effective due to backtracking caused by the engine.
Any idea on how to avoid it?
Bonus: It's pretty funny that the regex engine does not recognize the fact that it searches [^\s] one by one in \s* and causes this amount of backtracking. What are the problems with the engine?
Bonus 2: Using only the stdlib re module. Since I can not add third parties. (I was technically looking for using sublime text, but want to know how to do this in general in Python)
source share