daily pastebin goal
7%
SHARE
TWEET

Untitled

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