0

How to format a regular expression In JavaScript :

http://localhost:3000/sales?&tp=Home+Stay&am=Pool&pl=1620&pt=Flash+Sale&st=5

I want to get &pl= and all the digits after &pl=. So the result would be &pl=1620 in this case. Please help how to perform this?? Your help means a lot for me.

1

2 Answers 2

0

This script will do the trick:

var regex = /&pl=\d*/;
var match = regex.exec(yourtext)[0];
Sign up to request clarification or add additional context in comments.

2 Comments

ok, how I will assign it to Variable , because after it I want to split using that variable. for example => if I write var num = &pl=\d* then it gives a syntax error. Please help.
Thanks a lot Mr. LeviBotelho.
0

Following regex should do it

/&pl=\d*/.exec('http://localhost:3000/sales?&tp=Home+Stay&am=Pool&pl=1620&pt=Flash+Sale&st=5')[0]

Demo: Fiddel

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.