Skip to content

Instantly share code, notes, and snippets.

@CaiJingLong
Last active February 7, 2020 06:51
Show Gist options
  • Save CaiJingLong/f9007e26535d3e5f6dfd3cfdf343b69c to your computer and use it in GitHub Desktop.
Save CaiJingLong/f9007e26535d3e5f6dfd3cfdf343b69c to your computer and use it in GitHub Desktop.
regex match @words
main(List<String> arguments) {
final r = RegExp(r'\s(@(\S+))');
final str = '@abc adkj sfksjdlfj@@@fjdlksjf @abc@aa df @@@ccc @dfj @你好';
final matches = r.allMatches(" " + str);
for (final match in matches) {
// print(match.group(1)); // 带@符号的
print(match.group(2)); // 不带@符号的
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment