?
Solved

How to find string using search in java script

Posted on 2014-07-21
3
Medium Priority
?
152 Views
Last Modified: 2014-07-23
Hi,
I have a string

var str = www.abc.com?<useridentifier>=[@ANaccount]

now in above string i want to search   ?<useridentifier>=[@ANaccount]

I have tried using search below
var str1 = str.search("\\?<useridentifier>=[@ANaccount]");

but this one is not working

can u please correct me above code
0
Comment
Question by:mannevenu26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:Raghu Mutalikdesai
ID: 40210708
Try this way:
var idx = str.indexOf("\\?<useridentifier>=[@ANaccount]");
var str1 = str.substring(idx, str.length - 1);

Open in new window

0
 

Author Comment

by:mannevenu26
ID: 40210727
var idx = str.indexOf("\\?<useridentifier>=[@ANaccount]"); not getting value getting idx as -1
0
 
LVL 11

Accepted Solution

by:
Radek Baranowski earned 2000 total points
ID: 40210855
do it exactly as in

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28480214.html#a40208907

var str = "www.abc.com?<useridentifier>=[@ANaccount]";

var check=new RegExp ("[\?<useridentifier>=\[@ANaccount\]]");

//this will output position of "?" for testing purposes
if(check.test(str)==true) alert(str.search('\\?'));
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question