doutuo7609 2016-06-26 11:37
浏览 53
已采纳

PHP - 使用preg_replace()仅字符串的特定部分

I have a string, for example:

-Website URL***Image URL

I want to use preg_replace() to replace the ***Image URL with an empty string, look like string here:

-Website URL

I always have problem with preg_replace().

Please help me! Thank you!!!!

  • 写回答

2条回答 默认 最新

  • dopuzf0898 2016-06-26 12:00
    关注

    Take all after the minus at string beginning and till 3 stars

    $res = preg_replace('/^-?(.+)\*{3}.+$/', '\1', '-Website URL***Image URL');
    echo $res;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?