开发者

How to write Regex to find stock and Price

var rawItemInfo={"stock":"In Stock","shipping":"<em>Free Shipping</em>","finalPrice":"56.99","itemInfo":"<div class=\"grpPricing\"><div class=\"wrapper\"><div class=\"current\" id=\"singleFinalPrice\"><span class=\"label\">Now:  开发者_运维百科</span><span>$</span>56<sup>.99</sup></div></div><div 

I want to extract two information from above string

1: Stock Status "In Stock" which will come always after "Stock":

2 Price $56.99 which is there

some before....<span>$</span>56<sup>.99</sup> some code after....

Please help me out to write regex for these two information.


You can extract these value using this code

var regPattern = "stock\":\"(.*?)\",\".*?finalPrice\":\"(.*?)\"";
Regex regex = new Regex(regPattern);
var data = regex.Match(contact.Name);
data.Groups[1].Value ///"In stock. Limit 1 per customer."
data.Groups[2].Value ///"549.99"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜