Check If whole String Matches Regex of Arithmetic Operation in C#

Viewed 21

I need to check if a string matches a basic arithmetic operation (+,-,*,/) with exactly one operator, e.g.

1232+4564 is a match 213/546 is a match 546-654 is a match 789*44 is a match 1231+63218-6846 is not a match 879 is not a match 1531/ is not a macth 1321-4654 is not a match I have tried this

`

    private void valid()
    {
        if (!Regex.IsMatch("some string",@"\d+[\+-*/]\d+"))
        {
            errorForm.SetError(operacionTextBox, "Ingrese operacion de la forma \\d+[+,-,*,/]\\d+");

        }
    }

`

0 Answers
Related