It is a powerful way of searching and replacing something inside a string. To implement that we can use RegExp class and integrated with strings.
In Regular expressions we need pattern and optional flags.
So we have 2 ways –
var regexp = new RegExp("pattern", "flags");
var regexp = /pattern/g; // g is flag it's opptional
How to use
let str = "I am working on JavaScript!"; // will search here
let regexp = /working/;
console.info( str.search(regexp) ); // 2
Flags
we can use –
i – For case-insensitive
g – For all matches
m – For Multiline mode
u – For Enables full unicode support
y – For Sticky mode