So I’ve been working on some website validation in javascript and I am pretty new to using Regex. This is the Regex I created to validate Social Security Numbers that have a hyphen in between the three sections.
/^d{3}[-]d{2}[-]d{4}$/
and then In my research I came across a site called Trellix and I’ll attach a link to their site where I found it because they have a lot more Regex than just the SSN that I’m interested in. This is there Regex code that validates for hyphens in between the three sections
/(?:b(?:0[1-9][0-9]|00[1-9]|[1-5][0-9]{2}|6[0-5][0-9]|66[0-5789]|7[0-2][0-9]|73[0-3]|7[56][0-9]|77[012])-(?:0[1-9]|[1-9][0-9])-(?:0[1-9][0-9]{2}|00[1-9][0-9]|000[1-9]|[1-9][0-9]{3})b)/
Their Regex is a lot longer than mine and as far as I can tell from comparing mine to theirs on regex101.com I am unable to tell a difference they both seem to work and do the same thing. If so why is theirs so much longer? Does it account for something more I’m not realizing? Is my Regex good enough for this case of validation?
If Trellix Regex is better should I try to use more of their Regex listed on their site for my own purposes?
Trellix.com