如何在正则表达式中允许字符,空格和点? [英] how to allow characters, space and dot in regular expression?

查看:63
本文介绍了如何在正则表达式中允许字符,空格和点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ValidationExpression="^[a-zA-Z ]+$"

这是我当前的正则表达式,但不接受.(.).我需要用它来命名.例如" Reynante A. Capco "

this is my current regular expression but it does not accept .(dot). I need to use it for names. like "Reynante A. Capco"

推荐答案

以下表达式将全部获取

  • 字符(a-zA-Z)
  • 空格(\ s)和
  • 点(\.)

在字符串开头(^)和结尾($)之间:

between the string beginning (^) and end ($):

在字符串中用反斜杠将'@'引起来.

The '@' is necessary to quote the backslashes inside the string.

ValidationExpression=@"^[a-zA-Z\s\.]+$"

这篇关于如何在正则表达式中允许字符,空格和点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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