0

How could I provide @mention list during typing in AutoCompleteTextBox ?

Pattern of my mention is like:

   String pattern = "@[a-zA-Z0-9_.]+?(?![a-zA-Z0-9_.])";

Sample: consider user try to type two mention and even try to edit one of them, and text is like:

Thank you @marvel308 and @Dav for answering my question

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73

1 Answers1

1

You can simplify your regex. Try this code:

var input = "Thank you @marvel308 and @Dav for answering my question";
var regex = new Regex("@(?<name>[^\\s]+)");
var results = regex.Matches(input)
    .Cast<Match>()
    .Select(m => m.Groups["name"].Value)
    .ToArray();
Aleks Andreev
  • 7,016
  • 8
  • 29
  • 37