This will work
^\d{4}-\d{3,4}-[23]$
Regex Breakdown
^ #Start of string
\d{4} #Match 4 digits
- #Match - literally
\d{3,4} #Match 3 or 4 digits
- #Match - literally
[23] #Match 2 or 3
$ #End of string
More Related Contents:
- I need php regular expression to allow the all leters, numbers, dollar sign, commas, double & single quotes [closed]
- PHP / Regex: detect string after ?>
- Regex For a Simple Validation [closed]
- Warning: preg_replace(): Unknown modifier
- Extract URLs from text in PHP
- Remove all special characters from a string [duplicate]
- PHP: Regex to ignore escaped quotes within quotes
- Get content between two strings PHP
- How to remove non-alphanumeric characters?
- What does the “[^][]” regex mean?
- Split camelCase word into words with php preg_match (Regular Expression)
- RegExp to strip HTML comments
- RegEx pattern to get the YouTube video ID from any YouTube URL
- Get Youtube Video ID from html code with PHP
- How to add hyphen to regex
- Regular Expression to collect everything after the last /
- Extra backslash needed in PHP regexp pattern
- Change single variable value in querystring [closed]
- How to check, if a php string contains only english letters and digits?
- php regex to get string inside href tag
- Tilde operator in Regular expressions
- How to prefix a positive number with plus sign in PHP
- Converting Javascript Regex to PHP
- Extract floating point numbers from a delimited string in PHP
- Youtube I.D parsing for new URL formats
- PHP and regexp to accept only Greek characters in form
- How to validate that a string only contain lowercase letters?
- Regular expression: find range except for one letter or a range
- Regex to match an IP address [closed]
- PHP’s preg_replace regex that matches multiple lines