dpleylxzx47207117 2018-10-18 23:20
浏览 79
已采纳

正则表达式PHP部分字符串[重复]

This question already has an answer here:

I cant get my regexpression to work in php. It works in javascript (vuejs):

(?<=.+: )(.*)

I have this string:

NL: abcdef

and i would like to get

abcdef

Can someone please tell me what i am doing wrong?

</div>
  • 写回答

1条回答 默认 最新

  • dream1849 2018-10-18 23:32
    关注

    There are many ways to solve this using PHP/PCRE, one is to skip the preceding string using \K

    [^:]+: \K(.*)
    

    Regex Demo

    If you can add an anchor to the beginning of the string, even better: ^[^:]+: \K(.*)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?