| | |
Regular Expression Help!
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I need to check if two parameter names exists in the url. If any of them do i need to replace the value of the parameter.
I can match the parameter name, but i am not sure how to replace the value. The two parameters/values would be at the end of the url.
what i have so far is below.
I was thinking about something like below. but i want to replace the parameter value and not the name
I can match the parameter name, but i am not sure how to replace the value. The two parameters/values would be at the end of the url.
what i have so far is below.
HTML and CSS Syntax (Toggle Plain Text)
url = “http://www.daniweb.com?parm1=value&parm2=value&parm3=value&parm4=value // can i combine these some how? var parm3RegExp = /parm3=/; var parm4RegExp = /parm4=/; // finds parm3. Now how can i replace the value? url = parm3RegExp.exec(url)
I was thinking about something like below. but i want to replace the parameter value and not the name
HTML and CSS Syntax (Toggle Plain Text)
var url = url.replace(/parm3=/, "");
Got this to work.
I will just remove the parameters and the values if they are present in the url. Then run the logic to create and add the paramters and there values to the url, if they are needed.
I will just remove the parameters and the values if they are present in the url. Then run the logic to create and add the paramters and there values to the url, if they are needed.
HTML and CSS Syntax (Toggle Plain Text)
url = “http://www.daniweb.com?parm1=value&parm2=value&parm3=value&parm4=value var urlParm3loc = url.search(/&parm3=/); var urlParm4loc = url.search(/&parm4=/); if(urlParm3loc > 0 || urlParm4loc > 0) { var startIndex = urlParm3loc > urlParm4loc ? urlParm4loc : urlParm3loc ; url = url.replace(url.substring(startIndex,url.length),""); }
![]() |
Similar Threads
- Regular Expression (Perl)
- How to write javascript regular expression for this case? (JSP)
- regular expression (PHP)
- Regular Expression Matching New Line (Perl)
- Regular expression (Perl)
- Looking for table rows with Regular expression. (PHP)
Other Threads in the HTML and CSS Forum
- Previous Thread: Image Swap help
- Next Thread: Rotating flash movies per page load
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7





