Java中正则表达式的重音 [英] Accent in Regular Expression in Java

查看:150
本文介绍了Java中正则表达式的重音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Hibernate Validator验证一些列。据我所知,问题是java中的\w标记不接受带有重音符号的字母。

I'd like to use Hibernate Validator to validate some columns. The problem, as I understand, is that the \w marker in java doesn't accept letters with accents on them.

有没有办法可以写出regexp这样像Relatório这样的词可以被验证(我不想写括号之间带有重音的所有字母,因为我希望在很多列中写这个正则表达式)?

Is there any way that I could write the regexp so that words like Relatório could be validated (i wouldn't want to write all letters with accents between brackets, because I expect to be writing this regexp in a lot of columns)?

推荐答案

Java正则表达式文档有一节关于Unicode类别(搜索Unicode块和类别的类)。如果您只是在寻找信件,我认为 \p {L} 是您想要的类别。

The Java regex documentation has a section on Unicode categories (search for "Classes for Unicode blocks and categories"). If you're just looking for letters, I think \p{L} is the category you want.

这篇关于Java中正则表达式的重音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆