简体   繁体   English

正则表达式,无空格黑白文本

[英]regular expression for no blank space b/w text

请告诉我如何检查正则表达式没有空格黑白文本。

If you mean "What's the reqular expression to check there is no white space in a string", the following pattern will work: 如果你的意思是“要检查的是什么是reqular表达式,字符串中没有空格”,则以下模式将起作用:

^[\S]*$

This will find any string that only contains non-white space (spaces, new lines, tabs, etc). 这将找到任何只包含非空格(空格,换行符,制表符等)的字符串。

I don't know if it is the regular expression you are looking for but, [:space:] will match any whitespace character, while [:blank:] will match space and tab characters only. 我不知道它是否是您正在寻找的正则表达式,但是, [:space:]将匹配任何空格字符,而[:blank:]将仅匹配空格和制表符。

Both are used inside square brackets, eg [[:space:]] 两者都用在方括号内,例如[[:space:]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM