Skip to content

Different Browsers Handle Regex Differently

Daisho Komiyama edited this page Jan 14, 2018 · 2 revisions

Hi, I've just found a weird behaviour about handling regular expressions.

Chrome

This world's most popular browser takes French accents (e.g. é, à, û) as word characters therefore \w matches é, à or û.

Firefox and Safari

However other browser such as Firefox and Safari take French accents as nonword characters therefore \w won't match é, à neither û.

If you want to write match pattern safely, you will have to be explicit for French accents.

i.e. write pattern a-zàâäèéêëîïôœùûüÿç to match all French accents.

Chrome is great browser and I love it but it's not good idea to count on it too much as this browser is sometimes too generous to be used for development. It covers minor errors without complaining.

*I didn't check with IE as it's not a browser. It's a downloader for downloading a browser.

Clone this wiki locally