// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text.RegularExpressions; namespace E { public class Program { public static void Main(string[] args) { string s = "bla bla 1.96 bla"; Regex re = new Regex(@"\d+\.\d+"); if(re.IsMatch(s)) { Console.WriteLine(re.Match(s).Value); } string s2 = @"bla bla 123.45 ""price"":""1.96"" bla bla"; Regex re2 = new Regex(@"(?:""price"":"")(\d+\.\d+)(?:"")"); if(re2.IsMatch(s2)) { Console.WriteLine(re2.Match(s2).Groups[1].Value); } } } }