开发者

JavaScript RegExp

I thought I'd try and be clever with some JavaScript and use a regexp instead of repeated use of the indexOf method. I failed. Miserably.

I would like t开发者_开发百科o try and match anything (using the test method) in the following order:

predefined string + space + forward slash + one digit number: 3-8 + decimal point

Can someone tell me what the regexp would be?


Assuming the predefined string is myString:

/myString \/[3-8]\./

Breakdown:

myString    - predefined string (including space)
\/          - Forward slash
[3-8]       - A digit (between 3-8)
\.          - A .

A good resource for regular expressions is http://www.regular-expressions.info/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜