Try the following:
$find = '/jsfile\.js\?(version=)?[0-9]*</';
?
makes the preceding element optional, and parentheses create a group, so (version=)?
means "optionally match version=
". Note that I also escaped the ?
from earlier in the regular expression, since you want this to match a literal ?
and not make the s
optional.
In addition, I switched from double to single quotes to ensure the escaping works properly, if you were to use double quotes you would want to escape each backslash, for example:
$find = "/jsfile\\.js\\?(version=)?[0-9]*</";