I want to extract sub strings from a string using regex in flutter.
Eg: if string is "HI hello @shemeer how are you @nijin"
, the expected result will be [shemeer,nijin]
Input : String s= "HI hello @shemeer ul haq how are you @nijinsha rah"
Output: output=["shemeer ul haq","nijinsha rah"]
Is anybody knows it, please help me
2
Answers
You can split the string into words and then look for
@
and generate list based on it.Or use
allMatches
withRegExp(r'@w+')
as pskink mentioned on comment.You could try to use this regex pattern:
(?<=@)w+