I have the following which is part of a url keyword/with/some/stuff/following
I need a regex (PHP) that would give me the same result as
explode('/', 'keyword/with/some/stuff/following');
In this case an array of matches like the following
array('keyword', 'with', 'some', 'stuff', 'following')
I've tried a few things including stuff from stackoverflow but without any luck
This would do it:
([^\/]+)
Working regex example
PHP
preg_match_all("/([^\/]+)/", "keyword/with/some/stuff/following", $matches);
$matches[1] =
array("keyword", "with", "some", "stuff", "following")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.