Reputation: 8484
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.
Upvotes: 2
Views: 1564
Reputation: 839114
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.
Upvotes: 4