help
Root Question Message
var word = "iahdsoihdaiiadi1124I ID:whatever sidaohiow12";
var match = Regex.Match(word, @"ID:(.*)");
var id = match.Groups[1].Value;
Console.WriteLine(id);
int idIndex = str.IndexOf("ID:");
int idStartIndex = idIndex + "ID:".Length;
int spaceIndex = str.IndexOf(" ", idStartIndex);
string id = str[idStartIndex .. spaceIndex];
str[idStartIndex..spaceIndex]
gives you the substring from idStartIndex
(inclusive) to spaceIndex
(exclusive).*
will match everything after ID:
. You could add a space after the capture group and then do .*?
instead([\w\d]+)
instead of (.*?)
. This way you don't need to match the space afterwards