|It's a good few years since I wrote RegExps and, even when I did, I could never remember whether ^ was start and $ was end or if it was the other way round.
My totally untested guess is (assuming spaces are only allowed between components and / or at the start or end) is
or allowing spaces between any numbers (and / or at the start or end) is
Note: I'm allowing all whitespace, to just explicitly permit spaces and exclude other white space, change all of the
\s patterns to single space chars
I look forward to seeing what someone who actually knows RegExps comes up with to see if I am even remotely close.
Edit: I've just re-read the question - you want to extract the text, not just validate it. What I have written above just validates. A simple way to extract would be to, enclose the whole of the text between
theGroupThatYouHaveFound.Replace(/\s/g, '');. An even simpler way would be to use the validation RegExp and then remove spaces from the original string (no messing around with groups).
modified 7-Apr-22 12:58pm.