Skip to content

Commit cb85a40

Browse files
committed
添加 => 08 字符串
1 parent 73d7828 commit cb85a40

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

08-字符串/string.dart

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
void main() {
2+
// 单引号或者双引号
3+
// String a = 'ducafecat';
4+
// String b = "ducafecat";
5+
6+
7+
// 字符串模板 ${expression} 表达式
8+
// var a = 123;
9+
// String b = 'ducafecat : ${a}';
10+
// print(b);
11+
12+
13+
// 字符串连接
14+
// var a = 'hello' + ' ' + 'ducafecat';
15+
// var a = 'hello'' ''ducafecat';
16+
// var a = 'hello' ' ' 'ducafecat';
17+
// var a = 'hello'
18+
// ' '
19+
// 'ducafecat';
20+
// var a = '''
21+
// hello word
22+
// this is multi line
23+
// ''';
24+
// var a = """
25+
// hello word
26+
// this is multi line
27+
// """;
28+
// print(a);
29+
30+
// 转义符号
31+
// var a = 'hello word \n this is multi line';
32+
// print(a);
33+
34+
// 取消转义 raw 字符串
35+
// var a = r'hello word \n this is multi line';
36+
// print(a);
37+
38+
// 搜索
39+
// var a = 'web site ducafecat.tech';
40+
// print(a.contains('ducafecat'));
41+
// print(a.startsWith('web'));
42+
// print(a.endsWith('tech'));
43+
// print(a.indexOf('site'));
44+
45+
// 提取数据
46+
// print(a.substring(0,5));
47+
// var b = a.split(' ');
48+
// print(b.length);
49+
// print(b[0]);
50+
51+
// 大小写转换
52+
// print(a.toLowerCase());
53+
// print(a.toUpperCase());
54+
55+
// 裁剪 判断空字符串
56+
// print(' hello word '.trim());
57+
// print(''.isEmpty);
58+
59+
// 替换部分字符
60+
// print('hello word word!'.replaceAll('word', 'ducafecat'));
61+
62+
// 字符串创建
63+
// var sb = StringBuffer();
64+
// sb..write('hello word!')
65+
// ..write('my')
66+
// ..write(' ')
67+
// ..writeAll(['web', 'site', 'https://ducafecat.tech']);
68+
// print(sb.toString());
69+
70+
}

0 commit comments

Comments
 (0)