Ok, i have a regex pattern like this /^([SW])\\w+([0-9]{4})$/
This pattern should match a string like SW0001
with SW
-Prefix an
Let's see what the regex /^([SW])\w+([0-9]{4})$/
match
\w
= [a-zA-Z0-9_]
)This match more than just SW0001
.
Use the below regex.
/^SW\d{4}$/
This regex will match string that starts with SW
followed by exactly four digits.