I want to validate a cell reference in an Excel sheet formula.
Valid strings:<ol> <li>
I am using following expression but it is not working.
Regex re = new Regex(@"^=('?[^']+'?|[^!]+)![A-Z]+[0-9]+$"); bool isOk = re.IsMatch("=Sheet1!A1");
[^!] to whatever characters you do not want in the sheet's name.
It will match anything with the format
=<anything>!XN where X is at least one uppercase letter and N is at least one digit.
I am not sure if OP wants the
= character at the start or not (the original post had it). If you don't, remove the
= character from the start of the regular expression.
Oh some other problem.
Its working now
this one should work: =?(\s|\w)+![A-Za-z]+\d+