Here is the code :)
static void TextBuffer_regularExpression(Args _args)
{
TextBuffer txt = new TextBuffer();
str msg = "98797897";
;
txt.setText(msg);
txt.regularExpressions(true); // activate regular expr in search
// Regular expression to validate only digits
if (txt.find("^[0-9]+$"))
{
info("string contains only numbers");
}
}
{
TextBuffer txt = new TextBuffer();
str msg = "98797897";
;
txt.setText(msg);
txt.regularExpressions(true); // activate regular expr in search
// Regular expression to validate only digits
if (txt.find("^[0-9]+$"))
{
info("string contains only numbers");
}
}
If you want to validate only chars just use [a-z] instead of [0-9]
Happy Daxing!
Aucun commentaire:
Enregistrer un commentaire