php regex to get string inside href tag

后端 未结 9 2175
忘了有多久
忘了有多久 2020-11-30 10:11

I need a regex that will give me the string inside an href tag and inside the quotes also.

For example i need to extract theurltoget.com in the following:

         


        
9条回答
  •  無奈伤痛
    2020-11-30 10:37

    Because Positive and Negative Lookbehind are cool

    /(?<=href=\").+(?=\")/
    

    It will match only what you want, without quotation marks

    Array ( [0] => theurltoget.com )

提交回复
热议问题