如何找出字符串中以#开头的单词

Lal*_*wat 2 string dart flutter

我想找出所有以#开头的单词。

例如=这是一个#tag

我想创建这个(#tag)可点击并将其颜色更改为蓝色。请指教一下!

Text("This is a #tag"),
Run Code Online (Sandbox Code Playgroud)

Ste*_*lli 5

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)