C# has two types of string literals - regular and verbatim.
String Literals | C# Language Specification | Microsoft Docs[
^]
You are using a regular string literal, which means you need to escape certain characters by prefixing them with
\
. For a literal
\
, you need to double it up:
[RegularExpression("(^1300\\d{6}$)|(^1800\\d{6}$)", ErrorMessage = "Entered number must be start with 1300 or 1800")]
Alternatively, you could use a verbatim string literal by prefixing the string with
@
:
[RegularExpression(@"(^1300\d{6}$)|(^1800\d{6}$)", ErrorMessage = "Entered number must be start with 1300 or 1800")]