Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Scripting language Interviews:AngularJSAngularJS DeveloperChrome FrameDojoExpert Developer JavaScriptExpert JavaScript DeveloperExt CoreEXT-GWTExt-JSFront End Developer (AngularJS)JQuery DeveloperjQuery MobileJQuery ProgrammerJQuery UIMooToolsPrototype FrameworkQooxdooScriptingSencha TouchSizzle Selector EngineSWFObjectWeb Font LoaderXMLHttpRequest
Copyright © 2018. All Rights Reserved
JQuery Programmer Interview Question:
What are the approaches of extracting a query string with regular expressions?
Submitted by: AdministratorAd
There are two approaches of doing so:
1. String based approach : This is the simple way of extracting the information of a query string using the string-based replacement technique. This method makes use of the .replace() method to function.
For ex :
var data = string.replace("http://localhost/view.php?", "");
The above code works fine for the string based approach but has some flexibility issues. It cannot deal effectively with domain name and file name changes.
2. Regular expression approach : They are a powerful pattern matching tool available in modern programming languages. For the extraction of a query string a pattern would have to be used which looks for a question mark in the string. Once it does it returns everything after it. The regular expression in JS are delimited using the forward slashes at the end of an expression.
Submitted by:
1. String based approach : This is the simple way of extracting the information of a query string using the string-based replacement technique. This method makes use of the .replace() method to function.
For ex :
var data = string.replace("http://localhost/view.php?", "");
The above code works fine for the string based approach but has some flexibility issues. It cannot deal effectively with domain name and file name changes.
2. Regular expression approach : They are a powerful pattern matching tool available in modern programming languages. For the extraction of a query string a pattern would have to be used which looks for a question mark in the string. Once it does it returns everything after it. The regular expression in JS are delimited using the forward slashes at the end of an expression.
Submitted by:
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.

https://InterviewQuestionsAnswers.ORG.
