Room of a pleinolijf

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


Leave a comment

Alphabetical Regular Expression for Non-English Languages

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])+