我的目标是从/photos/
$file
之后的用户名
$file = '/photos/plant_a/sort,"1,528","1,278",00:10:21,"1,263"
/photos/forest-b/nosort,"1,528","1,278",00:10:21,"1,263"
/photos/soil_c1/,"1,528","1,278",00:10:21,"1,263"
/photos/jungle_c2,"1,528","1,278",00:10:21,"1,263"';
preg_match_all('~/photos/(.+?)/~', $file, $matches);
print_r($matches[1]);
此选项仅输出plant_a
,forest-b
和soil_c1
,但不输出jungle_c2
。
这些是用户名,可以包含_
,-
和数字。一旦出现逗号,就意味着该URL的结尾。
如何提取juncle_c2
?
答案 0 :(得分:3)
我认为这是有效的
inside findMyLocation * inside didUpdateLocations * Latitude: -26.204103 Longitude: 28.0473051inside sendDataToServer *
inside didUpdateLocations * Latitude: -26.204103 Longitude: 28.0473051inside sendDataToServer *
inside didUpdateLocations * Latitude: -26.204103 Longitude: 28.0473051inside sendDataToServer *
编辑(因为有关换行符的评论):~/photos/([^/]+)~
第二次编辑(自下次评论以来):~/photos/([^/\r\n]+)~