var a = 123; String b = 'ducafecat : ${a}'; print(b);
字符串连接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
var a = 'hello' + ' ' + 'ducafecat'; var a = 'hello'' ''ducafecat'; var a = 'hello'' ''ducafecat'; var a = 'hello' ' ' 'ducafecat'; var a = ''' hello word this is multi line '''; var a = """ hello word this is multi line """; print(a);
转义符号
1 2
var a = 'hello word \n this is multi line'; print(a);
取消转义
1 2
var a = r'hello word \n this is multi line'; print(a);
搜索
1 2 3 4 5
var a = 'web site ducafecat.tech'; print(a.contains('ducafecat')); print(a.startsWith('web')); print(a.endsWith('tech')); print(a.indexOf('site'));
提取数据
1 2 3 4
print(a.substring(0,5)); var b = a.split(' '); print(b.length); print(b[0]);
大小写转换
1 2
print(a.toLowerCase()); print(a.toUpperCase());
裁剪 判断空字符串
1 2
print(' hello word '.trim()); print(''.isEmpty);
替换部分字符
1
print('hello word word!'.replaceAll('word', 'ducafecat'));