Reputation: 429
I'm pretty new with regular expressions. I'm trying to write a regular expression for a space followed by the word "IN" followed by another space.
So basically " IN ". I will eventually do a case insensitive split with it.
Regex regex = new Regex(*REG EX*, RegexOptions.IgnoreCase);
string[] parts = regex.Split(strValue);
Upvotes: 0
Views: 66
Reputation: 158
This should do:
Regex regex = new Regex(@"\s{1}IN\s{1}");
string[] split = regex.Split(input);
Upvotes: 0
Reputation: 969
Your *REG EX*
should be " IN "
.
(Seriously, its " IN "
)
Regex regex = new Regex(" IN ", RegexOptions.IgnoreCase);
In case, if you have other whitespace characters i.e., other than space(
), you can always use Juan's solution(
"\s+IN\s+"
). Here,\s
means any whitespace character.
Upvotes: 1