using variable n regex c# -


this question has answer here:

         var d = new date();         string[] weekday = new string[10];         weekday[0] = "söndag";         weekday[1] = "måndag";         weekday[2] = "tisdag";         weekday[3] = "onsdag";         weekday[4] = "torsdag";         weekday[5] = "fredag";         weekday[6] = "lördag";         int day = (int)datetime.now.dayofweek;         var n = weekday[day];          var match = regex.match(item.innertext, @"\b" + n + "\s(.*)\s(.*)\s(.*)", regexoptions.multiline);          response.write(match.value); 

i "unrecognized escape sequence" error on \s(.)\s(.)\s(.) when put in variable. works fine when it's @"\bmåndag\s(.)\s(.)\s(.)", regexoptions.multiline);

you can use @ regex

var match = regex.match(item.innertext, @"\b" + n + @"\s(.*)\s(.*)\s(.*)", regexoptions.multiline); 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -