Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Unrecognized escape sequence

Tags:

c#

regex

I have following Regex on C# and its causing Error: C# Unrecognized escape sequence on \w \. \/ .

string reg = "<a href=\"[\w\.\/:]+\" target=\"_blank\">.?<img src=\"(?<imgurl>\w\.\/:])+\"";
Regex regex = new Regex(reg);

I also tried

string reg = @"<a href="[w./:]+" target=\"_blank\">.?<img src="(?<imgurl>w./:])+"";

But this way the string "ends" at href=" "-char

Can anyone help me please?

like image 526
Crazywako Avatar asked Dec 03 '22 23:12

Crazywako


1 Answers

Use "" to escape quotations when using the @ literal.

like image 74
Gjeltema Avatar answered Dec 26 '22 04:12

Gjeltema