Topics
Mind Fresher Games
Books Deals
Hot Questions
Hot Answers
New Questions
Ask a Question
Explore
Ask a Question
Programming
How to check a String contains another sub string using...
How to check a String contains another sub string using JavaScript
+1
vote
511
views
asked
in
Programming
by
raman
(
530
points)
I am trying to verify that a string contains another sub string , Because I am using JavaScript so String.contains() method is not working in this case.
Please help me out on this. Thanks For your help!
javascript
string
Your answer
Thanks for contributing your answer!
Please be sure to answer the question. Provide details with examples and share your research!
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
1
Answer
0
votes
answered
by
monika
(
2.8k
points)
First of all i would like to let know about indexOf() its a method which returns index within the calling String ,When it does not found any value so it returns -1.
For more
info
of indexOf()
See this code here:
var s = "foo";
alert(s.indexOf("oo") > -1);
I hope you got my point.
Your comment on this answer:
Use comments to reply to other users or notify them of changes. If you are adding new information, edit your post instead of commenting.
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Not a Member yet?
My Account
531
Folks are online
7
members and
524
guest online
Related questions
How to check a string contains a specific word in php?
How to store current context to local variable using JavaScript
How to remove a specific string from array in PHP?
How to remove line breaks from a string in java?
How to Get Some Specific Characters From a String In Java?
How to write a multiple line String Array in java?
How to remove comma or unwanted characters from a string?
I want to find different occurrences of a sub string within string using regex?
How can i split a string value in different parts?
How to center a paragraph of text on a particular word in HTML, CSS, or JavaScript?
Best way to Convert a String having Decimal point to Double?
onClick a button redirect to a URL in JAVASCRIPT
How to Change String to Lower Case or Upper case in Java?
how to set cookies in JavaScript
How to create a jQuery price Range slider ?
JavaScript: Select and Delect all check box on click one check box
get multiple bytes from a string
JavaScript- Open a new tab while focusing on an old tab
I want to append to an array in Javascript is it possible?
javascript- how to redirect page using jQuery
Categories
All categories
Software Testing
(48)
Programming
(130)
Interview Questions
(28)
My Career
(1)
Puzzles
(4)
Motor Bikes
(11)
Travel
(9)
Electronics
(1)
Entertainment
(2)
OTHER
(18)
Recent
Popular Questions
Registration and login form in PHP?
Tell me best places to visit during holi in india?
What is the best time to visit and the best way to get to the Taj Mahal?
JavaScript- Open a new tab while focusing on an old tab
What should I know before visiting Jim Corbett National Park?
Tell me best places to visit during holi in india?
What is the best time to visit and the best way to get to the Taj Mahal?
What should I know before visiting Jim Corbett National Park?
How to download COVID vaccination certificate and correct personal details?
How to book Vaccine slot quickly ?
All categories
Software Testing
(48)
Programming
(130)
Interview Questions
(28)
My Career
(1)
Puzzles
(4)
Motor Bikes
(11)
Travel
(9)
Electronics
(1)
Entertainment
(2)
OTHER
(18)
Your feedback is highly appreciated