How To Search And Find Text In A String In Javascript
- Forums
- Javascipt
- How To Search And Find Text In A String In Javascript
i will show you how you can search for text in a string with javascript find a letter or number in a string javascript [833], Last Updated: Sat May 18, 2024
wallpaperama
Tue Oct 18, 2011
0 Comments
433 Visits
i learned something new today, if you are familiar with regular expression in php, you can also search for text in a string with javascript.
its easy, in javascript you can use the search() functions.
lets say i have a string like this:
var MyString = 'wallpaperama';
and i want to check if the word wallpaper exists in the MyString variable. i can use this code for example:
if(MyString.search('wallpaper'){
alert('I found it');
}
you would get a alert saying: I found it
cool!! give me your comments