Wesukilaye

Your choices please me, for now


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 搜索

Dart 字符串

发表于 2019-08-08 分类于 Dart
本文字数: 1.3k 阅读时长 ≈ 1 分钟
定义+拼接
单引号或者双引号的创建与拼接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
String a = 'abc';
String b = "abc";
//相邻字符串创建
var c = 'hello' + ' ' + 'world';
var b = 'hello'' ''world';
var d = 'hello' ' ' 'world';

var e = 'hello'
' '
'world';

var f = '''
hello world
this is multi line
''';

var g = """
hello world
this is multi line
""";

var h = 'hello'',world'",OK";
转义字符
1
2
3
4
5
var s1 = 'In a raw string, not even \n gets \t special treatment.';
print(s1);
//结果
In a raw string, not even
gets special treatment.

加r,可以识别转义字符

1
2
3
4
var s = r'In a raw string, not even \n gets \t special treatment.';
print(s);

In a raw string, not even \n gets \t special treatment.
搜索
1
2
3
4
5
var a = 'hello world';
print(a.contains('wo')); //true
print(a.startsWith('h')); //true
print(a.endsWith('d')); //true
print(a.indexOf('llo')); //2
提取数据
1
2
var a = 'hello world';
var b = a.split(' ');
大小写转换
1
2
print(a.toLowerCase());
print(a.toUpperCase());
替换
1
print('hello world world!'.replaceAll('world', 'abc'));
  • 本文作者: Mr.Zhao
  • 本文链接: https://wesukilayezcy.github.io/2019/08/08/Dart-字符串/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
Dart String
Swift 字典
Dart list
-------------本文结束感谢您的阅读-------------
  • 文章目录
  • 站点概览
Wesukilaye

Wesukilaye

熟练使用iOS Objective-c,Swift. 了解Python爬取网络数据,深入研究移动端开发,目前正在学习Flutter
23 日志
4 分类
16 标签
RSS
GitHub E-Mail bilibili
Links
  • Jacksu
  1. 1. 定义+拼接
    1. 1.1. 单引号或者双引号的创建与拼接
    2. 1.2. 转义字符
  2. 2. 搜索
  3. 3. 提取数据
  4. 4. 大小写转换
  5. 5. 替换
© 2019 Wesukilaye | 62k | 57 分钟
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Pisces v7.3.0