我是PHP和REGEX的新手。我有一个字符串像下面的
{"fileName":"#DH_BCDN_BASE_URL#/fetchdata16/images/fe/ef/b4/feefb4aab5683517f5ff01b5d479bbd7f50e7fa3fb462d259d110c8c8143b921.jpg","width":1000,"height":999}
我想要字符串仅在#/之后和之前";,所以它需要低于
fetchdata16/images/fe/ef/b4/feefb4aab5683517f5ff01b5d479bbd7f50e7fa3fb462d259d110c8c8143b921.jpg
我不知道怎样才能达到目标。这里有人能帮我吗?
谢谢!
在这种情况下,您可以使用爆炸轻松解析
$json = '{"fileName":"#DH_BCDN_BASE_URL#/fetchdata16/images/fe/ef/b4/feefb4aab5683517f5ff01b5d479bbd7f50e7fa3fb462d259d110c8c8143b921.jpg","width":1000,"height":999}';
//parse the json
$json = json_decode($json);
$str = explode("#/", $json->fileName)[1];
echo $str;
您可以在此处查看:https://www.tehplayground.com/LlWImdvpR145fE81