Reputation: 567
I am trying to make a pattern that will return if a string has the following formating:
yyyy / mm / dd
( please note that they are 4 spaces in that string ).
The following code is what I have come with so far, but it still can't detect the space character. Any ideas how to make it work ?
RegExp( /^\d{4}[\s\/\s]\d{2}[\s\/\s]\d{2}$/g ).test( "1234 / 11 / 22" );
RegExp( /^\d{4}[ \/ ]\d{2}[ \/ ]\d{2}$/g ).test( "1234 / 11 / 22" );
Thanks
Upvotes: 0
Views: 201
Reputation: 17480
RegExp( /^\d{4}\s\/\s\d{2}\s\/\s\d{2}/g ).test( "1234 / 11 / 22" );
Upvotes: 0