Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System;
- using System.Text.RegularExpressions;
- public class Test
- {
- public static void Main()
- {
- var text = "123456789";
- var res = Regex.Replace(text, @"^((?<ch>.)*).((?<-ch>.)*(?(ch)(?!))$)", @"$1$2");
- Console.WriteLine(text);
- Console.WriteLine(res);
- }
- }
- string input = "aaa bbbb ccccc dddddd";
- string pattern = @"w+";
- string RemoveCentralSymbol(string s) => s.Remove(s.Length / 2, s.Length % 2);
- var result = Regex.Replace(input, pattern, match => RemoveCentralSymbol(match.Value));
- Console.WriteLine(result);
Add Comment
Please, Sign In to add comment