fork(1) download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string removed = string.Empty;
  9. string rest = ReFormat("PHOTO;TYPE=PNG;ENCODING=B:/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMoHBwYIDAoMDAsK\r\nCwsNDhIQDQ4KL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJB\r\nTEL;TYPE=CELL:123456789", out removed);
  10. Console.WriteLine(removed);
  11. Console.WriteLine(rest);
  12.  
  13. }
  14. private static String ReFormat(String str, out String removed)
  15. {
  16. Regex rgx = new Regex(@"(?msi)^(?<removed>PHOTO\b.*?)(?=\b(?:TEL|EMAIL|END)\b)");
  17. removed = rgx.Match(str).Groups["removed"].Value;
  18. return str.Replace(removed, string.Empty);
  19. }
  20. }
Success #stdin #stdout 0.08s 24472KB
stdin
Standard input is empty
stdout
PHOTO;TYPE=PNG;ENCODING=B:/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMoHBwYIDAoMDAsK
CwsNDhIQDQ4KL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
BhJB

TEL;TYPE=CELL:123456789