-
.search()
.match()
.replace()
with RegExp
- RegExp is a sequence of characters that form a search pattern. Syntax:
/pattern/modifiers;
. - Modifiers:
i
(perform case-insensitive match). Return the index of the first match.
.match(/char/g)
performs global match, doesn't stop after find the first matched. It will return an array containing all the matching result.
m
(perform multiline matching)
-
.search()
and.replace()
are case-sensitive, adding RegExp can make it case-insensitive.
2.
const first = string.indexOf(searchString)
const second = string.indexOf(searchString, (first +1));
//starts from the position after the first index
3..split()
const str = 'ssss=dddd';
const back = str.split('=')[1];
console.log(back). //output: 'dddd'
console.log(str.split('')) //output: [
's', 's', 's',
's', '=', 'd',
'd', 'd', 'd'
]
Top comments (0)