Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace RegexTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- string Test1 = "Kov ács Lá szl ó";
- string Test2 = "Ád ámk a Ö dö n";
- string Test3 = "Sc hä ffer Brü n hil da Kl ár a";
- Console.WriteLine("Regex:");
- Console.WriteLine("{0} -> {1}", Test1, GetName(Test1));
- Console.WriteLine("{0} -> {1}", Test2, GetName(Test2));
- Console.WriteLine("{0} -> {1}", Test3, GetName(Test3));
- Console.ReadLine();
- }
- private static string GetName(string text)
- {
- string s = "";
- string rxNevCI = @"([\p{Lu}\p{Lt}\p{Lo}\p{Lm}][\p{Ll}\p{Lo}\p{Lm}\s']*[\p{Ll}\p{Lo}\p{Lm}'])";
- Regex rx = new Regex(rxNevCI, RegexOptions.CultureInvariant);
- MatchCollection mc = rx.Matches(text);
- foreach(Match m in mc)
- s += m.Value.Replace(" ", "") + " ";
- s = s.Trim();
- return s;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement