Regex for french characters fails validation based on the position of french character

时间:2019-01-07 13:21:51

标签: regex unicode french

In my code I had a Password RegEx (written by someone) (/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\x20-\x7E]{8,40}$/) which was not supporting french characters. And I modified it a bit to support french characters. And /^(?=.*[a-z])(?=.*[A-Z])(?:.*[àâäæèéêëîïôœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ]*)(?=.*\d)[\x20-\x7E]{8,40}$/ is the new RegEx. But this one does not work as expected. The behavior changes with the position of the french character. For example, NewàTest123! - works and NewTàest123! does not works

Any thoughts on why it fails when the position of the character changes?

1 个答案:

答案 0 :(得分:0)

正则表达式工作

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\x20-\x7EàâäæèéêëîïôœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ]{8,40}$

感谢@WiktorStribiżew