match multiple words instead of a single word
i have the following regex:
private string tokenRegEx = @"\[%RC:(\w+)%\].*?";
which is when i pass in the string below it finds it:
However the following returns false
how can i modify the regex to allow for spaces as well as whole words?
You need to change the \w pattern (which matches alphanum plus underscore only) to something more liberal. For example this would also allow whitespace:
private string tokenRegEx = @"\[%RC:((\w|\s)+)%\].*?";
Of course the "correct" solution would need to take into account exactly what you consider acceptable input, which is kind of open to discussion at this point.