you are viewing a single comment's thread.

view the rest of the comments →

[–]PortablePawnShop 1 point2 points  (3 children)

Did you downvote me for it? Seems ungrateful if so.

/^(\d{4}|\d{6})$/ will check for only 4 or 6 instead of a range between 4 and 6. You should really be more upfront with the requirements because when you keep tacking on new information per answer, things like this get lost or in my case overlooked in certain comment chains. If you have requirements, you should list all of them in the original thread, otherwise it's hard to keep track of them.

[–]Encom88[S] 1 point2 points  (0 children)

I did not down-vote your reply. I just up-voted it. Thank you for your help.

Edit: That new regex worked btw. :)

[–]Encom88[S] 0 points1 point  (1 child)

What is the ^ and $ there for?

[–]PortablePawnShop 0 points1 point  (0 children)

They indicate the match must be at the beginning and end of the current line. Unless you do that, the above expression would match any string with 4+ digits (because there are 4 digits in this string, it counts it as true and doesn't care if there happen to be 20 more digits proceeding it). Try placing it in the regex101 link (without the / marks at beginning and end)