Extracting groups from money matches : Regex Money : Regular Expression C# Examples


C# Examples » Regular Expression » Regex Money »

 

Extracting groups from money matches









    
using  System;
using  System.Collections.Generic;
using  System.Globalization;
using  System.Text;
using  System.Text.RegularExpressions;
using  System.Reflection;

public  class  MainClass{

      public  static  void  Main(){
                Regex  r  =  new  Regex(@"\$((\d{1,3},)*\d+)\.(\d{2})");
                Match  m  =  r.Match("$1,035.66,100.99");
                Console.WriteLine("Dollar  part:  {0},  cents:  {1}",
                        m.Groups[1].Captures[0].Value,  m.Groups[3].Captures[0].Value);
      }
}
    
   
  
   



Output

Dollar part: 1,035, cents: 66


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Regular Expression
» Regex Money