using javascript regex to capture text in a url -



using javascript regex to capture text in a url -

i need utilize regular look in javascript match text in url.

here example:

"qty1=0&qty2=0&qty3=0&"

i want match text(number) comes after '=' , before '&' whenever word 'qty' appears in string. text(number) subject alter every time url generated, want match whatever new text(number) may be.

what regular look utilize solve this?

any help appreciated!

var querystr = "qty1=0&qty2=0&qty3=0"; var regex = /qty(\d+)=(\d+)/g; var match = regex.exec(querystr); while(match != null){ var numbeforeequals = match[1]; var numafterequals = match[2]; // comparison, example, if it's > 0: if(numafterequals > 0){ // } match = regex.exec(querystr); }

note /g @ end of regex, in javascript implementations end infinite loop without it.

javascript

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -