Say I have the following: preg_match("/ESP[0-9]?[0-9]/", $devid)
I want to match data such as the following:$devid = "ESP1"$devid = "ESP10"$devid = "ESP78"
However, I don't want the string to contain anything that isn't matched in the regex. For example:
$devid = "ESP100" would return ESP10$devid = "ESP10234234" would return ESP10$devid = "ESP78hello" would return ESP78
...and if there isn't a match, returning null (or equivalent).
In a way, I want to detect where preg_match finishes, and then remove the rest.