JavaScript String search() Method with Practical Examples

Free Web development courses with real-time projects Start Now!!

Program 1

"use strict"
const ps=require("prompt-sync")
const prompt=ps({sigint:true})
let s1=prompt("Enter a string")

//console.log(s1.indexOf("MP"))
//console.log(s1.lastIndexOf('f'));

//console.log(s1.search(/free/))
//console.log(s1.includes('free'))
console.log(s1.match(/free/gi))

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *