It allows 0 or more elements that are not a space, than a single space and selects whatever comes after that space. Dollar ($) matches the position right after the last character in the string. To match start and end of line, we use following anchors: Caret (^) matches the position before the first character in the string. In regex, anchors are not used to match characters. But if a match is found in some other line, it returns null. So, if a match is found in the first line, it returns the match object. This method checks for a match only at the beginning of the string. Re.match () function will search the regular expression pattern and return the first occurrence. To get that first space as well in result string change expression to *(. var input = "bobs nice house" var afterSpace = Regex.Match(input, "* (.*)").Groups.Value afterSpace is "nice house".
re.match () function will search the regular expression pattern and return the first occurrence. This replacement pattern references text that has been captured by the regex - in this case, all the text up to the first space. This one is trickier to use: you have to replace with \1. *?$, which needs the multi-line modifier to work.