字母数字和空格的正则表达式 [英] Regular Expression for alphanumeric and space

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

问题描述

除了空格以外不能包含任何特殊字符的文本的常规exp是什么?

What is the regular exp for a text that can't contain any special characters except space?

推荐答案

因为布拉格只想匹配空格,而\s不能匹配所有空格字符,包括换行符和制表符。

Because Prajeesh only wants to match spaces, \s will not suffice as it matches all whitespace characters including line breaks and tabs.

在所有RegEx解析器中普遍适用的字符集是:

A character set that should universally work across all RegEx parsers is:

[a-zA-Z0-9 ]

进一步的控制取决于您的需求。字边界,多行支持等...我建议您访问 Regex库,该库还具有指向各种库的链接正则表达式解析工作原理的教程。

Further control depends on your needs. Word boundaries, multi-line support, etc... I would recommend visiting Regex Library which also has some links to various tutorials on how Regular Expression Parsing works.

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

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