Last active
February 7, 2020 06:51
-
-
Save CaiJingLong/f9007e26535d3e5f6dfd3cfdf343b69c to your computer and use it in GitHub Desktop.
regex match @words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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