i've got following 2 types of output need regex match & replace on:
<span class=price>$9.99</span> <span class=regularprice>$9.99</span><span class=saleprice>$4.99</span>
what i'm looking match $9.99 in first example; , $4.99 in 2nd. (basically match contents of tag if class either price or saleprice
i've tried few examples; either match entire span; or start saleprice , go forward
what i've got is:
var regex = new regex(@"<span class=price|saleprice>(.*?)<\/span>");
but it's off little bit somewhere. think alternation isn't quite right; can point me in right direction?
lucky enough, .net supports variable-length lookbehinds:
(?<=<span\s+class=\1?(?:price|saleprice)(['"])?>)([^<]*)(?=<\/span>)
i added single/double quotes matching pattern around class names, since valid html should have it.
Comments
Post a Comment