*me, blindfolded, throwing a dart at a spinning board that, in addition to '80s tabletop RPGs', has things like 'learn a new skill' and 'volunteering'*
Don't ever leave a lock in the unlocked state. You want to avoid situations where a person can lock something (either intentionally or from just fidgeting) but not unlock it. In the worst case, this can be fatal. Keeping it locked makes you prove you have the key before using it.
You have a problem. You use regular expressions. You now have solved your problem with a tool used by thousands and thousands of engineers for decades.
The average length of time between when you solve a problem and when you learned the information used to solve it is called your "rubber band quotient". Just kidding, it's not actually called that.
@WHALEINFO Remember when Bush said "I know the human being and fish can coexist peacefully"? People mocked him for that but I genuinely believe that it's a beautiful hope.