I think that what you are trying to do is this:
if(preg_match('/^revision-(?[0-9]+)$/', $str, $matches)) {
echo "Edit ". $matches[0];
} elseif(preg_match('/revision/', $str)) {
echo "Edit 1";
} else {
echo "Auto save";
}
Explanation:
- ̛'^' means 'starts with'
- (? ) tells the regular expression to save the
match it encloses
- [0-9] means all characters from 0 to 9
- '+' means one or more times
- '$' means 'ends with'
Put that all together, and you have a regular expression meaning
If the string contains only 'revision', a dash, and a number, save the number and output it as the Edit number. Otherwise output 'Auto Save'.