There's this simple regular expression that has got me stumped. I was hoping someone could shed some light on this.
Here's my expression.
preg_match('/(.*)(i)?/','quit',$args);
print_r($args);
/*
Example 1.
Array
(
[0] => quit
[1] => quit
)
*/
preg_match('/(.*)(i)/','quit',$args);
/*
Example 2.
Array
(
[0] => qui
[1] => qu
[2] => i
)
*/
If someone could explain why both these expression don't produce the same results. Aside from the first having '?'.
Essential what I want is the result displayed in 'Example 2', with the '(i)' being optional.