|
151 | 151 | // console.log(s.padEnd(10));//"abc_ _ _ _ _ _ _" it returns with 7 space
|
152 | 152 | // console.log(s.padEnd(10,'foo'));// "abcfoofoof" <-- it returns
|
153 | 153 | // console.log(s.padEnd(10,'123456789'));// "abc1234567" <-- it returns
|
| 154 | + |
| 155 | + |
| 156 | + // LOCALCOMPARE() // |
| 157 | +// SYNTAXES // |
| 158 | +//referenceString.localCompare(compareString); |
| 159 | +//referenceString.localCompare(compareString, locales); |
| 160 | +//referenceString.localCompare(compareString, locales , options) |
| 161 | + |
| 162 | + // SEARCH() METHOD // |
| 163 | +// SYNTAXES // |
| 164 | +//string.search(regexp) |
| 165 | +// let text = 'The rain in SPAIN stays mainly in the plain'; |
| 166 | +// console.log(text.search('ain')); |
| 167 | +// console.log(text.search(/ain/)); |
| 168 | +// console.log(text.search(/AIN/)); |
| 169 | +// console.log(text.search(/AIN/i));// at the moment it searches both case on the lowerCase and upperCase and returns first find item position |
| 170 | +// console.log(text.search(/w/));//if item will not find it returns "-1" all the time |
| 171 | + |
| 172 | + |
| 173 | + // MATCH() // |
| 174 | + // SYNTAXES // |
| 175 | +// string.match(regexp) |
| 176 | + |
| 177 | +// let text = 'The rain in SPAIN stays mainly in the plain'; |
| 178 | +// console.log(text.match('ain'));//hte uotput --> [ |
| 179 | +// // 'ain', |
| 180 | +// // index: 5, |
| 181 | +// // input: 'The rain in SPAIN stays mainly in the plain', |
| 182 | +// // groups: undefined |
| 183 | +// // ] |
| 184 | + |
| 185 | +// console.log(text.match(/ain/)); // sme result as "search()" method |
| 186 | +// console.log(text.match(/ain/g));//it returns how many "comparestring" available inside of string |
| 187 | +// console.log(text.match(/ain/gi));//it returns how many "comparestring" available inside of string but both cases lowerCase and UpperCase |
| 188 | +// console.log(text.match(/w/));// if method failed it returns "null" |
0 commit comments