FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jString.js/jstring.js at master · justJavaScript/jString.js · GitHub
justJavaScript
jString.js
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
jString.js
/
jstring.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (54 loc) · 1.6 KB
Breadcrumbs
jString.js
/
jstring.js
Copy path
File metadata and controls
64 lines (54 loc) · 1.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// ( 1 ) String.contains()
String
.
prototype
.
contains
=
function
(
text
)
{
if
(
text
==
''
)
return
true
;
else
if
(
text
==
null
)
return
false
;
else
return
this
.
indexOf
(
text
)
!==
-
1
;
}
// ( 2 ) String.count()
String
.
prototype
.
count
=
function
(
text
)
{
if
(
this
.
contains
(
text
)
)
return
this
.
split
(
text
)
.
length
-
1
;
else
return
0
;
}
// ( 3 ) String.capitalize()
String
.
prototype
.
capitalize
=
function
(
)
{
if
(
this
==
''
)
return
this
;
else
return
this
.
charAt
(
0
)
.
toUpperCase
(
)
+
this
.
slice
(
1
)
.
toLowerCase
(
)
;
}
// ( 4 ) String.trim()
String
.
prototype
.
trim
=
function
(
)
{
return
this
.
replace
(
/
^
\s
+
|
\s
+
$
/
g
,
''
)
;
}
// ( 5 ) String.leftTrim()
String
.
prototype
.
leftTrim
=
function
(
)
{
return
this
.
replace
(
/
^
\s
+
/
,
''
)
;
}
// ( 6 ) String.rightTrim()
String
.
prototype
.
rightTrim
=
function
(
)
{
return
this
.
replace
(
/
\s
+
$
/
,
''
)
;
}
// ( 7 ) String.clear()
String
.
prototype
.
clear
=
function
(
)
{
return
this
.
replace
(
/
^
\s
+
|
\s
+
$
/
g
,
''
)
.
replace
(
/
\s
+
/
g
,
' '
)
;
}
// ( 8 ) String.startsWith()
String
.
prototype
.
startsWith
=
function
(
start
)
{
if
(
start
==
''
)
return
true
;
else
if
(
start
==
null
||
start
.
length
>
this
.
length
)
return
false
;
else
return
this
.
substring
(
0
,
start
.
length
)
==
start
;
}
// ( 9 ) String.endsWith()
String
.
prototype
.
endsWith
=
function
(
end
)
{
if
(
end
==
''
)
return
true
;
else
if
(
end
==
null
||
end
.
length
>
this
.
length
)
return
false
;
else
return
this
.
indexOf
(
end
,
this
.
length
-
end
.
length
)
!==
-
1
;
}
// ( 10 ) String.insert()
String
.
prototype
.
insert
=
function
(
text
,
at
)
{
if
(
at
==
null
||
at
>
this
.
length
)
at
=
this
.
length
;
else
if
(
at
<
0
)
at
=
0
;
return
this
.
substring
(
0
,
at
)
+
text
+
this
.
substring
(
at
)
;
}
Back
|
FazBrowse Home
|
New Git URL