[英]regex to select everything between slashes without the slashes
I have the following which is part of a url keyword/with/some/stuff/following
我有以下内容是url
keyword/with/some/stuff/following
I need a regex (PHP) that would give me the same result as 我需要一个正则表达式(PHP),它会给我相同的结果
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 我尝试过一些东西,包括来自stackoverflow的东西,但没有任何运气
This would do it: 这样做:
([^\/]+)
Working regex example 工作正则表达式的例子
PHP PHP
preg_match_all("/([^\/]+)/", "keyword/with/some/stuff/following", $matches);
$matches[1] = $ matches [1] =
array("keyword", "with", "some", "stuff", "following")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.