普通的前pression赶上超越A-Z的字母 [英] Regular expression to catch letters beyond a-z

查看:90
本文介绍了普通的前pression赶上超越A-Z的字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个正常的正则表达式允许字母只将的[A-ZA-Z]的,但我来自瑞典所以我不得不改变成的[A- zåäöA-ZÅÄÖ]的。但是,假如我不知道字母是用什么字母。

A normal regexp to allow letters only would be "[a-zA-Z]" but I'm from, Sweden so I would have to change that into "[a-zåäöA-ZÅÄÖ]". But suppose I don't know what letters are used in the alphabet.

有没有办法来自动知道什么是字符在给定的语言环境/语言有效的,或者我应该只是做字符,我(我想)的黑名单知道,我不想?

Is there a way to automatically know what chars are are valid in a given locale/language or should I just make a blacklist of chars that I (think I) know I don't want?

推荐答案

您可以使用\\ PL匹配任何'信',这将支持所有语言的所有字母。你可以使用命名块'范围缩小到特定的语言。更多信息可以在字符类在MSDN文档中找到。

You can use \pL to match any 'letter', which will support all letters in all languages. You can narrow it down to specific languages using 'named blocks'. More information can be found on the Character Classes documentation on MSDN.

我的建议是把常规的前pression(或至少是信的一部分)到一个本地化的资源,然后你就可以拔出基于当前的区域,形成到更大的格局。

My recommendation would be to put the regular expression (or at least the "letter" part) into a localised resource, which you can then pull out based on the current locale and form into the larger pattern.

这篇关于普通的前pression赶上超越A-Z的字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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