-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.html
More file actions
46 lines (40 loc) · 1.2 KB
/
string.html
File metadata and controls
46 lines (40 loc) · 1.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- <script>
//문자열 검색
let s = "A bad workman always blames his tools.";
let n = s.indexOf("workman");
document.write(n + '<br>'); // 6
</script>
<script>
//문자열 매칭
let str = 'Like father, like son.';
// like를 찾는다. i와 g는 옵션으로 insensitive, globally를 의미한다.
result = str.match(/like/ig);
document.write(result + '<br>');
</script>
<script>
//문자열 대체
let p = 'The quick brown fox jumps over the lazy dog.';
document.write('dog', 'cat'+"<br>");
let regex = /Dog/i;
document.write(p.replace(regex, 'cat'))+"<br>";
</script>
<br>
<script>
// 문자열 분할
let ss = "One,Two,Three,Four,Five";
array = ss.split(',');
for (i = 0; i < array.length; i++) {
document.write(i + '-' + array[i] + '<br>');
}
</script> -->
</body>
</html>