0

I need a regular expression to match a word exactly and immediatly followed by some digits in javascript.

In the below example url, i have to match exactly -t followed by digits 10, digits may change.

in the below url, it should match -t and 10.

priceangels.com/mouse-pads-t10.html

another example url :priceangels.com/apple-t275.html, here it should match -t followed by 275.

please help me with explanation.

1
  • 1
    What have you tried ? Here's a good site for testing regular expressions: regexpal.com Commented Mar 13, 2014 at 11:48

3 Answers 3

1

How about:

var regex = /-t\d+/;
Sign up to request clarification or add additional context in comments.

Comments

1

Try with this regular expression:

.*-t([\d]+).*

Comments

0

this will satisfy for words other than t also, like

qwertu10 in priceangels.com/mouse-pads-qwertu10.html

baba10 in priceangels.com/mouse-pads-baba10.html

/(?=\-)-(\w+\d+)/g

demo here http://regex101.com/r/jN7wK2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.