views:

68

answers:

4

Hi All,

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/Send/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 i change the textbox value for s1alt text

A: 

You could operate with the following regex:

&s1=([^&]*)(&|$)
bazmegakapa
A: 

You can replace using this regex

url.replace(/&s1=([^$]+|[^&]+)/i, "&s1=newvalue");
BrunoLM
A: 

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}', ...);
Vantomex
Vantomex
i need to check is s1 is exist or not
Nisanth
A: 

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+\$_.-]*)?\$

amit