What's a good regex to include accented characters in a simple way?

后端 未结 4 1121
死守一世寂寞
死守一世寂寞 2020-12-14 02:12

Right now my regex is something like this:

[a-zA-Z0-9] but it does not include accented characters like I would want to. I would also like - \' , to be included.

4条回答
  •  渐次进展
    2020-12-14 03:03

    A version without the exclusion rules:

    ^[-'a-zA-ZÀ-ÖØ-öø-ÿ]+$
    

    Explanation

    • The ^ anchor asserts that we are at the beginning of the string
    • [...] allows dash, apostrophe, digits, letters, and chars in a wide accented range,
    • The + matches that one or more times
    • The $ anchor asserts that we are at the end of the string

    Reference

    • Extended ASCII Table

提交回复
热议问题