Room of a pleinolijf

Ask yourself this: how do I want to be remembered ?

Alphabetical Regular Expression for Non-English Languages

Leave a comment

Just a quick tip I want to put out there. Whenever you need to match alphabetical characters using a RegEx in an environment that will contain non-english languages (which have diacritics like à, é, õ, Ü, ç, etc…) you can do so like this:

[a-zA-ZÀ-ÿ]

By the way, don’t make my mistake of shortening it to :

[A-ÿ]

Because that will include a number of special characters like the dollar and ampersand signs.

You can use the pattern as an input filter to disallow any characters that are not alphabetic (but allow an apostrophe and a whitespace for example):

([^a-zA-ZÀ-ÿ’\s])+

Advertisements

Author: pleinolijf

father | volleyballer | software engineer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s