I have a text field have value http://localhost/Send/test.php?s/?a=1&o=2
. Another three text boxes. If we enter three values the above url will change like http://localhost/Sen开发者_如何学Pythond/test.php?s/?a=1&o=2&s1=a&s2=b&s3=c
. The value for s1,s2
and s3
will not save anywhere. My question is how we check is the value for s1
is already set? And how can I update the value of s1
if iI change the textbox value for s1
You can replace using this regex
url.replace(/&s1=([^$]+|[^&]+)/i, "&s1=newvalue");
I guest you use PCRE in PHP:
(?=(?P<ES1>.*&s1=)?)(?(ES1)RegexToMatchIfS1AlreadyExist|RegexToMatchIfS1NotExist)
So
$result = preg_replace('/^(?=(?P<ES1>.*&s1=)?)(?(ES1)(?P<Left>.*&s1=)(?P<Right>.*+)$|RegexToMatchIfS1NotExist)/', '${1}newvalue${2}', ...);
use this secure regular expression for every language...
^(https?|ftp)\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$
精彩评论