RegEx Pattern Question

Hi. Does anyone know how to valiate whether a string is in the following format using RegEx?

XXXX-XXXX-XXXX-XXXX

And can you specify the length of string required in the same RegEx pattern check or do you have to also do a separate Is string.Len = 19 check?

Thanks!

Short answer, yes.

What do the Xs represent?

Hi Kem. The Xs would be random characters but they must conform to that specific pattern.

So they can be any character at all? Then this would be the regular expression pattern:

\\A\\S{4}-\\S{4}-\\S{4}-\\S{4}\\z

\A = beginning of document
\S = not white space
{4} = repeat 4 times
\z = end of document

That’s perfect. Thanks for your help and for breaking down the pattern for me.