开发者

validating space in alphanumeric string thru regular expression

I am using the following regular expression

"[a-zA-Z0-9 \s]{4,}" 

to validate an alphanumeric entry with space and minimum length 4. but it doesn't accept spaces. what a开发者_运维知识库m i missing here.


This reference over here, under flag options says:

x If set, allow use of white space and #comments within patterns

It sounds like you need to set this x flag option for whitespace to work. If I understand it correctly, your regex should look something like

"(?x)[a-zA-Z0-9 \s]{4,}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜