Python non | python regular expression non greedy
Tostartwith,Idonotsuggestusing"*"inregexes.Yes,Iknow,itisthemostusedmulti-characterdelimiter,butitisneverthelessabadidea.Thisisbecause,whileitdoesmatchanyamountofrepetitionforthatcharacter,"any"includes0,whichisusuallysomethingyouwanttothrowasyntaxerrorfor,notaccept.Instead,Isuggestusingthe+sign,whichmatchesanyrepetitionoflength>1.Whatsmore,fromwhatIcansee,youaredealingwithfixed-lengthparenthesizedexpressions.Asaresult,youcanprobablyusethe{x,y}syntaxtospecificallyspecifythedesiredlength.H...
To start with, I do not suggest using "*" in regexes. Yes, I know, it is the most used multi-character delimiter, but it is nevertheless a bad idea. This is because, while it does match any amount of repetition for that character, "any" includes 0, which is usually something you want to throw a syntax error for, not accept. Instead, I suggest using the + sign, which matches any repetition of length > 1. Whats more, from what I can see, you are dealing with fixed-length parenthesized expressions. As a result, you can probably use the {x, y} syntax to specifically specify the desired length.
However, if you really do need non-greedy repetition, I suggest consulting the all-powerful ?. This, when placed after at the end of any regex repetition specifier, will force that part of the regex to find the least amount of text possible.
That being said, I would be very careful with the ? as it, like the Sonic Screwdriver in Dr. Who, has a tendency to do, how should I put i...