-
Notifications
You must be signed in to change notification settings - Fork 0
Description
It would be trivial to just add an optional opening parenthesis before and an optional closing one after, but this would mean that strings like "8:32 (GMT" would be valid.
This could be a good thing, converting times where people have typed sloppily, but it could introduce more bugs.
It would be more difficult to enforce having either both parentheses or neither. I'm not sure you can do this with regular expressions, apart from having the entire list of acronyms in there twice, once with parentheses around and once without. This seems like it would run at half the speed, and would also not be very scalable (do we add the list a third time to support square brackets?)
Other solutions, like incrementing a counter for every opening parenthesis and decrementing it for every closing one and checking if the total for the string is zero also sound slow, and overkill for a relatively rare format.
It seems like the best solution is to just support unmatched parentheses, but then if we add square brackets in future it would allow strings like "10:32 [GMT)".
Again, debatable whether this is a good thing or not. I'm leaning towards just allowing them unmatched, and reconsidering if it causes any problems.