Use:
^(\d?\d)\.(\d?\d)\.(\d?\d)$
That regex will match three groups of 1 or 2 digit numbers separated by dots. Examples:
preg_match("/^(\d?\d)\.(\d?\d)\.(\d?\d)$/", "1.0.0"); // Match
preg_match("/^(\d?\d)\.(\d?\d)\.(\d?\d)$/", "99.99.99"); // Match
preg_match("/^(\d?\d)\.(\d?\d)\.(\d?\d)$/", "99.699.99"); // Not match
manpreet
Best Answer
2 years ago
I have a PHP app that get's a play store app data and I want to check if the data I am getting is the version number.
A version number can be
0.0.1
to99.99.99
.How can I properly use regular expressions to handle this job?
This is how I currently do it: