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 string.
I want replace the old tags, attributes and content with the result of the called function.
The subject would be something like this:
<p>Some codesnippet:</p>
<span lang="fsharp">// PE001
let p001 = [0..999]
|> List.filter (fun n -> n % 3 = 0 || n % 5 = 0)
|> List.sum
</span>
<p>Another code snippet:</p>
<span lang="C#">//C# testclass
class MyClass {
}
</span>
In order to extract the value of the lang attribute and the content, I group those values with the following expression:
/(<span lang="(.*)">(.*)</span>)/is
Since regex tends to be greedy, This expression matches the complete subject, not just one span-tag and its content.
How do i manage to match just one span-tag?