简体   繁体   中英

Regular expression to exclude 0 or blank space

^[0 ]{1}\Z

I'm looking for a regular expression that targets 0 and a single blank space

This isn't working... what am I doing wrong?

It searches for any instance of 0 in a string. I don't want it to do that. I want it to ONLY find instances where the field has a '0' or if it is left blank.

10 <--- grabs 0 (should not do this)

以下正则表达式将检查字符 '0' 或 ' ' 是否只出现一次,并且它们是唯一提供的字符。

/^([0 ])$/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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