Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 904b226

Browse files
learned how i can use these methdos localCompare()search()match() in the String
1 parent 388114f commit 904b226

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

‎String methods/script.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,38 @@
151151
// console.log(s.padEnd(10));//"abc_ _ _ _ _ _ _" it returns with 7 space
152152
// console.log(s.padEnd(10,'foo'));// "abcfoofoof" <-- it returns
153153
// 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"

‎String methods/tempCodeRunnerFile.js‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /