using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"var\s(\w+)\s?\=\s?(\d+|\""[^\n""]*\""|\'[^\n']*\')\s?\;";
string input = @"<html>
<head>~~</head>
<body>
<div>contents</div>
<script>
var value1 = 55;var value2= 27;
var value3 = 'T';var value4 = ""FIT#$%SIZE"";
var value5 = '{\""P00000WJ000E\"":{\""stock_price\"":\""0.00\"",\""use_stock\"":true,\""use_soldout\"":\""T\"",\""is_display\"":\""T\"",\""is_selling\"":\""T\"",\""option_price\"":79000,\""option_name\"":\""FIT#$%SIZE\"",\""option_value\"":\""NOBLE-44\"",\""stock_number\"":26,\""option_value_orginal\"":[\""NOBLE\"",\""44\""],\""use_stock_original\"":\""T\"",\""use_soldout_original\"":\""T\"",\""use_soldout_today_delivery\"":\""F\"",\""is_auto_soldout\"":\""F\"",\""is_mandatory\"":\""T\"",\""option_id\"":\""000E\"",\""is_reserve_stat\"":\""N\"",\""item_image_file\"":null,\""origin_option_added_price\"":\""0.00\""}}';var value6 = '1';var value7 = 'string;must-catch';
var value8 = 8;
var value9 = 'S';
var value10 = 'T';
</script>
</body>
</html>";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx