1

can somebody help me to match following type of strings "BEREŽALINS", "GŽIBOVSKIS" in C# and js , I've tried

 \A\w+\z         (?>\P{M}\p{M}*)+             ^[-a-zA-Z\p{L}']{2,50}$

, and so on ... but nothing works . Thanks

tchrist
  • 78,834
  • 30
  • 123
  • 180
user872761
  • 13
  • 4
  • 4
    http://stackoverflow.com/questions/9558015/asp-net-use-czech-chars-in-regular-expression/9558058#9558058 – L.B Mar 23 '12 at 13:22

2 Answers2

0

Just wrote a little console app to do it:

    private static void Main(string[] args) {
        var list = new List<string> {
            "BEREŽALINS",
            "GŽIBOVSKIS",
            "TEST"
        };
        var pat = new Regex(@"[^\u0000-\u007F]");
        foreach (var name in list) {
            Console.WriteLine(string.Concat(name, " = ", pat.IsMatch(name) ? "Match" : "Not a Match"));
        }

        Console.ReadLine();
    }

Works with the two examples you gave me, but not sure about all scenarios :)

Spikeh
  • 3,540
  • 4
  • 24
  • 49
0

Can you give an example of what is should not match?

Reading your question it's like you want to match just string (on seperates line maybe). If thats the case just use

^.*$

In C# this becomes

foundMatch = Regex.IsMatch(SubjectString, "^.*$", RegexOptions.Multiline);

And in javascript this is

if (/^.*$/m.test(subject)) {
    // Successful match
} else {
    // Match attempt failed
}
buckley
  • 13,690
  • 3
  • 53
  • 61