Mar 28, 2012

How to validate the alphabets?


The below simple job checks that the given string contains only alphabets or not ...

static void TextBuffer_regularExpression(Args _args)
{
    TextBuffer txt = new TextBuffer();
    str msg = "ABCDEFGS";
    ;

    txt.setText(msg);
    txt.regularExpressions(true);   // activate regular expr in search


     // Regular expression to validate only alphabets
    if (txt.find("^[A-Z]+$"))
    {
        info("String contains only Alphabets");
    }
    else
    {
        info("String contains others characters");
    }

}

No comments: