Extracting "name = value" pairs (one per line)


using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {

         string r = @"(?m)^\s*(?'name'\w+)\s*=\s*(?'value'.*)\s*(?=\r?$)"; 
    
         string text = @"a = 3 s = t t= s"; 
    
         foreach (Match m in Regex.Matches (text, r)) 
            Console.WriteLine (m.Groups["name"] + " is " + m.Groups["value"]); 

    }
}

The output:


a is 3 s = t t= s
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.