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
Just adding ? , I think
/(<span lang="(.*?)">(.*?)</span>)/is
We'll never reapeat it again : do not use regular expressions to work with HTML !
Instead, use DOMDocument::loadHTML.
It'll allow you to manipulate your HTML data using the DOM, which is much more powerful and easier : you'll be able to :
Really : take the time to learn DOM : it's a great investment !
You can specify it to be ungreedy using ?
/(<span lang="(.*?)">(.*?)<\/span>)/is
or make all expression ungreedy by default using PCRE_UNGREEDY modifier
/(<span lang="(.*)">(.*)<\/span>)/Uis