- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if a string has a certain piece of 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>
- Related Articles
- Check if a string has white space in JavaScript?
- How to check if a string contains a certain word in C#?
- How to check if a string only contains certain characters in Python?
- How to check if an element has a certain class name with jQuery?
- How can tf.text be used to see if a string has a certain property in Python?
- MySQL query to check if a certain row has only two words?
- PHP program to check if a string has a special character
- C++ Program to check if a string has been seen before
- Check if a string is sorted in JavaScript
- How do I check if a string has alphabets or numbers in Python?
- JavaScript: How to Check if a String is a Literal or an Object?
- How to check if a string is a subset of another string in R?
- How to check if a date has passed in MySQL?
- How to check if a string has at least one letter and one number in Python?
- Java Program to check if the String contains only certain characters

Advertisements