
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check if a String Contains Certain Text in JavaScript
The jQuery search() method is used to check whether a string contains a certain text in JavaScript.
You can try to run the following code to check whether “Tutorialspoint: Free Video Tutorials” contains the “Free Video” text in JavaScript or not:
<html> <head> <title>JavaScript String search() Method</title> </head> <body> <script> var re = "Free Video"; var str = "Tutorialspoint: Free Video Tutorials"; if ( str.search(re) == -1 ) { document.write("Does not contain" ); } else { document.write("Contains" ); } </script> </body> </html>
Advertisements