SHARE
TWEET

Untitled

a guest May 24th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace ConsoleApp3
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string text = "eCheck payment for ^1 received. Receipt Date: 04/30/2019 from BANK OF AMERICA N.A. Checking Account ending in 5565.";
  12.             string pattern = @"eCheck payment for (\S+?) received. Receipt Date: (\b\S+?\b) from BANK OF AMERICA N.A. Checking Account ending in (\b\S+?\b).";
  13.  
  14.  
  15.             var placeholders = Regex
  16.                                 .Matches(text, pattern)
  17.                                 .OfType<Match>()
  18.                                 .SelectMany(m => m.Groups.OfType<Group>().Skip(1).Select(g => g.Value));
  19.  
  20.  
  21.             foreach (var variable in placeholders)
  22.                 Console.WriteLine(variable);
  23.  
  24.             /* OUTPUT
  25.              
  26.             ^1
  27.             04 / 30 / 2019
  28.             5565
  29.            
  30.              */
  31.             Console.Read();
  32.         }
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top