|go ahead... be a heretic
Re^2: Regex questionby BillKSmith (Monsignor)
|on Sep 17, 2023 at 21:04 UTC
If you truly believed that you always had a 'clean string', you would not need a regex test at all. Your latest regex would match any valid string and much more (in fact, nearly every "invalid_string" in my UPDATE). If you post a list of valid string which demonstrate the variation that is allowed and a list of invalid strings which demonstrate the types of errors you want to detect, we probably can make a simpler regex which does the job. You can modify my UPDATE to test a possible regex against all those strings.
Please note that every regex suggestion you have received is only one or two lines long. The best solution probably will be a better fit to your problem, but not much shorter.