I'm trying to use a regular expression to search for a pattern where the string will always be 5 lowercase letters, 2 numbers, and then a lower case p
.
Example:
ingja44p
I'm trying to use a regular expression to search for a pattern where the string will always be 5 lowercase letters, 2 numbers, and then a lower case p
.
Example:
ingja44p
There are many utilities on the internet that can help you author and test your own regular expressions. For this case, though, you might try something like this:
$subject = "String to test";
$pattern = "#[a-z]{5}\d{2}p#";
if (preg_match($pattern, $subject)) {
echo "A match was found.";
}
preg_match('/[a-z]{5}[0-9]{2}p/');
The / start and end the pattern: "/PATTERN/"
The [a-z]{5} means any lowercase letters a-z for length of 5
The [0-9]{2} means any 2 digits
p means, a "p" :)