How to create a regular expression in C# to search for non English, French and German characters.

I am trying to build a regular expression that can help me understand if a piece of text contains any characters outside of the English, French and German language sets.  More specifically any characters you can type on a standard English, German or French keyboard.

I have the task of going through millions of “words” – groups of characters wrapped with white spaces.

Any suggestions would be greatly appreciated.
rye004Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
how are they encoded? utf-8? or unicode?
unicode anything <=255 utf-8 anything not starting with c2 or if starting with c2 <=255
rye004Author Commented:
I have the words in a text file that is set to Unicode.  Many Thanks!
käµfm³d 👽Commented:
Since this is .NET, you should be able to list out all of the characters you care about using a character class:

e.g.

if (Regex.IsMatch(input, "[^a-zA-ZäöüÄÖÜß(french chars here)]"))
{
    // Found offending character
}

Open in new window


I'm afraid I don't speak/read French, so I don't know what the characters that are used within it are, but if you know them, then you should be able to just insert them in the advertised place in the above pattern--sans parens.
Bob LearnedCommented:
Regular expressions with Unicode characters are tricky, as explained here:

Unicode Regular Expressions
http://www.regular-expressions.info/unicode.html

Most people would consider à a single character. Unfortunately, it need not be depending on the meaning of the word "character".

All Unicode regex engines discussed in this tutorial treat any single Unicode code point as a single character. When this tutorial tells you that the dot matches any single character, this translates into Unicode parlance as "the dot matches any single Unicode code point". In Unicode, à can be encoded as two code points: U+0061 (a) followed by U+0300 (grave accent). In this situation, . applied to à will match a without the accent. ^.$ will fail to match, since the string consists of two code points. ^..$ matches à.

I believe that the key is to use a Unicode range in the character set [\u0000-\uFFFF].

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rye004Author Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.