REGEX: Grabbing everything until a specific word

后端 未结 1 658
醉话见心
醉话见心 2020-12-24 06:14

ex: example data in here

I want everything inside the a tag, to the end

/([^         


        
相关标签:
1条回答
  • 2020-12-24 06:45
    /<a>(.*?)<\/a>/
    

    should work. The ? makes it lazy, so it grabs as little as possible before matching the </a> part. but using . will mean that it matches everything until it finds </a>. If you want to be able to match across lines, you can use the following if with preg_match

    /<a>(.*?)<\/a>/s
    

    The "s" at the end puts the regular expression in "single line" mode, which means the . character matches all characters including new lines. See other useful modifiers

    0 讨论(0)
提交回复
热议问题