JS:
'abc/foln'.match(/[^\/]*?\/?$/); // ['foln']
PHP:
preg_match_all('/[^\/]*?\/?$/', 'abc/foln', $e); // ['foln', '']
preg_match_all('/\/[^\/]*?\/?$/', 'abc/foln', $e); // ['/foln']
preg_match_all('/\/?[^\/]*?\/?$/', 'abc/foln', $e); // ['/foln', '']
How can i achieve the same result in PHP as in JS?
And would be interesting to know why this difference.
preg_match_all('/[^\\/]*?\\/?$/', 'abc/foln', $e);in case the backslash needs to be escaped to a literal[^\/]*to[^\/]+so it doesn't match an empty string at the end.