Regex - Greedyness - matching HTML tags, content and attributes

前端 未结 3 888
梦如初夏
梦如初夏 2021-01-28 19:10

I am trying to match specific span-tags from an HTML source.

The lang-attribute and the inner HTML of the tag are used as parameters for a function which returns a new s

3条回答
  •  梦如初夏
    2021-01-28 20:04

    You can specify it to be ungreedy using ?

    /((.*?)<\/span>)/is

    or make all expression ungreedy by default using PCRE_UNGREEDY modifier

    /((.*)<\/span>)/Uis

提交回复
热议问题