Why this do not match and how to make it work?
Regex.Match("qwe", ".*?(?=([ $]))");
I should match everything to first space or to the end of line.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your specific problem is that you need to use an alternation, not a character class, because inside a character class the $ symbol literally means “match a dollar symbol”, and does not have its special meaning end-of-line in that context.
It seems however that your example is a bit strange. It would be simpler to match any character except space, then you wouldn’t need a lookahead at all.