GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — APIJSON-Demo/APIJSON-JavaScript/APIJSON-JS/StringUtil.js at master · ljxpall/APIJSON-Demo

Expand file tree

/

StringUtil.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
92 lines (82 loc) · 1.69 KB
/

StringUtil.js

Copy path

File metadata and controls

92 lines (82 loc) · 1.69 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**获取string,为null则返回''
* @param s
* @return
*/
function getString(s) {
return s == null ? '' : s;
}
/**获取去掉前后空格后的string,为null则返回''
* @param s
* @return
*/
function getTrimmedString(s) {
return this.getString(s).trim();
}
/**获取去掉所有空格后的string,为null则返回''
* @param s
* @return
*/
function getNoBlankString(s) {
return this.getString(s).replace('\\s', '');
}
/**判断字符是否为空
* @param s
* @param trim
* @return
*/
function isEmpty(s, trim) {
if (s == null) {
return true;
}
if (trim) {
s = s.trim();
}
if (s == '') {
return true;
}
return false;
}
/**添加后缀
* @param key
* @param suffix
* @return key + suffix,第一个字母小写
*/
function addSuffix(key, suffix) {
key = this.getNoBlankString(key);
if (key == '') {
return this.firstCase(suffix);
}
return this.firstCase(key) + this.firstCase(suffix, true);
}
/**首字母大写或小写
* @param key
* @param upper
* @return
*/
function firstCase(key, upper) {
key = this.getString(key);
if (key == '') {
return '';
}
const first = key.substring(0, 1);
key = (upper ? first.toUpperCase() : first.toLowerCase()) + key.substring(1, key.length);
return key;
}
/**全部大写
* @param s
* @param trim
* @return
*/
function toUpperCase(s, trim) {
s = trim ? this.getTrimmedString(s) : this.getString(s);
return s.toUpperCase();
}
/**全部小写
* @param s
* @return
*/
function toLowerCase(s, trim) {
s = trim ? this.getTrimmedString(s) : this.getString(s);
return s.toLowerCase();
}
//校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.