简体   繁体   English

正则表达式也接受“空白”字符

[英]Regular expression which accepts 'whitespace' character as well

This is my regular expression. 这是我的正则表达式。 But it does not accept white space. 但是它不接受空格。 How to modify it so that it will accept white space in the middle or end but should not accept only white spaces. 如何修改它,使其在中间或结尾接受空白,但不应仅接受空白。

    /^[a-zA-Z]+[a-zA-Z0-9._-]+$/'

The following should work for you. 以下应为您工作。 It will allow whitespace after the first character. 它会在第一个字符后留空格。 ^[a-zA-Z]+[a-zA-Z0-9\\s._-]+$

ya i got the solution.I modified the regex in the following way and this is working fine. 是的,我得到了解决方案。我以以下方式修改了正则表达式,这工作正常。 Anyway thanks :) 还是谢谢你 :)

    /^[a-zA-Z]+[a-z A-Z0-9._-]+$/'

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

相关问题 此正则表达式模式中的可选空格字符 - Optional whitespace character in this regular expression pattern 空白字符在不同浏览器中的正则表达式行为 - Whitespace character regular expression behavior in different browsers 需要接受表达式的字符串的正则表达式 - Need regular expression for a string which accepts expressions DFA的正则表达式,该表达式接受空字符串以及其他字符串 - Regular expression for a DFA that accepts the empty string as well as other strings 正则表达式匹配以某个字符或空格开头的行,然后是该字符 - Regular Expression match lines starting with a certain character OR whitespace and then that character 正则表达式,可在Java中接受多个用逗号分隔的电子邮件地址 - Regular expression which accepts multiple email addresses seperated by comma in java 正则表达式删除字符前字符串中间的空格 - Regular Expression to remove whitespace in the middle of a string before a character 正则表达式在任何空格前仅与字符匹配一次 - Regular expression to match a character only once before any whitespace POSIX扩展正则表达式中“空白”的特殊字符/转义符是什么? - What is the special character / escape for “whitespace” in a POSIX extented regular expression? 如果-字符后只有空格,则正则表达式匹配失败 - Regular expression match fails if only whitespace after the - character
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM