开发者

How do I combine 2 RegEx statements together, using JavaScript/RegEx?

I've been looking at RegEX's and don't know how to combine 2 regex statements together, for example

I have this JQuery code:

开发者_StackOverflow
$('.numeric').keyup(function () { 
    $(this).toggleClass('field-error', /\D/.test(this.value));
}); 

How do I combine this with the regex ^0 ...means any number begining with zero

Any help would be greatly appreciated, Thanks


You could use:

/^0|\D/

Which simply matches ^0 or \D.


/^0|\D/

Use the pipe (|) character to symbolize you want either the left or the right side.

e.g. to match apple, orange or banana you can use:

/apple|orange|banana/
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜