lpd
lpd

Reputation: 2337

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 to 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?

Upvotes: 0

Views: 356

Answers (1)

Oded
Oded

Reputation: 498992

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/

Upvotes: 4

Related Questions