Solved

How to find string using search in java script

Posted on 2014-07-21
3
143 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
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 500 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

749 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