Customer enters a unique 18 digit code which is written for example as 935 999 123 345 654 798

Salesperson at our company then enters that code in a monday text column. I want to validate that the number is 18 digits.

What i have done:
used the trim() function to leave one space between each word and then len(). I have then used conditional coloring to highlight the two correct values (18,23).

18 is the length of the string without spacing and 23 with one space between each.

I can now deal with:
A number with for example 20 digits without spacing.
a number with for example 20 digits but too much spacing between each word.

I cannot deal with exceptions where the sales rep has entered for example.
7359991111111 11111

I.e, correct number of digits but with one space.

Ideally i would need a formula to split the text string and join without spaces and then use len() formula. Any tips?

Im assuming {code} is a reference to the column which i have changed.

Im getting an error in the formula. Do you know of a way to debugg the code in monday? Im having trouble finding the issue as it is hard to decifer where is it going wrong.