What would the syntax to get all the words in a string after the first space. For example, bobs nice house. So the result should be " nice house" without the quote.
([^\s]+)
gives me all 3 words seperated by ;
,[\s\S]*$ >
not compiling.
I was really looking shortest possible code. following did the job. thanks guys
\s(.*)
I think it should be done this way:
[^ ]* (.*)
It allows 0 or more elements that are not a space, than a single space and selects whatever comes after that space.
C# usage
var input = "bobs nice house";
var afterSpace = Regex.Match(input, "[^ ]* (.*)").Groups[1].Value;
afterSpace
is "nice house"
.
To get that first space as well in result string change expression to [^ ]*( .*)
No regex solution
var afterSpace = input.Substring(input.IndexOf(' '));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With