Lal*_*wat 2 string dart flutter
我想找出所有以#开头的单词。
例如=这是一个#tag
我想创建这个(#tag)可点击并将其颜色更改为蓝色。请指教一下!
Text("This is a #tag"),
Run Code Online (Sandbox Code Playgroud)
You can achieve the desired result using RegEx in only 2 lines:
List<String> extractHashtags(String text) {
Iterable<Match> matches = RegExp(r"\B(\#[a-zA-Z]+\b)").allMatches(text);
return matches.map((m) => m[0]).toList();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1730 次 |
| 最近记录: |