daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest May 17th, 2018 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. using System;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9.   public static void Main()
  10.   {
  11.     var text = "123456789";
  12.     var res = Regex.Replace(text, @"^((?<ch>.)*).((?<-ch>.)*(?(ch)(?!))$)", @"$1$2");
  13.  
  14.     Console.WriteLine(text);
  15.     Console.WriteLine(res);
  16.   }
  17. }
  18.    
  19. string input = "aaa bbbb ccccc dddddd";
  20. string pattern = @"w+";
  21. string RemoveCentralSymbol(string s) => s.Remove(s.Length / 2, s.Length % 2);
  22. var result = Regex.Replace(input, pattern, match => RemoveCentralSymbol(match.Value));
  23. Console.WriteLine(result);
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
 
Top