I have a string that contains URL like parameters:
var params="f5=212&f1=255&f3=400&f6=789&f9=243"
I want to change the value of f1
, say from 255
to 355
.
But the problem is parameters are dynamic and location of individual parameter changes. Below are possible cases:
var params="f1=456&f5=212&f3=400&f6=789&f9=243"
var params="f5=212&f1=451&f3=400&f6=789&f9=243"
var params="f5=212&f3=400&f1=255&f6=789&f9=243"
var params="f5=212&f3=400&f6=789&f9=243&f1=123"
How can I create the regex to change f1
value correctly by JavaScript?