is the @variable word is always at the start of the string
try this
var stringHolder = "@variable(ID)";
if (stringHolder.Substring(0, "@variable".Length) == "@variable")
{
var getCode = stringHolder.Replace("@variable(", "").Replace(")", "");
}
I test my previous code,it gets error
I update my code and its work fine