Using regExpTest to verify Email and Phone number

Regular expressions (shortened as “regex”) are special strings representing a pattern to be matched in a search operation. They are an important tool in a wide variety of computing applications

Yeeflow provide the "regExpTest " function in expression editor that allows you to do the validation of strings. Here is an example about how to use “regExpTest” to verify the format of email address or phone numbers.

Assuming that you have a data list called employee details, which will be used as the database of internal employees:

Click the more operation button, and select form to create a new list form, or edit the existing new/edit form:

In the form designer, select the field “Office Email”, and click “Custom validation” under validation section.

Click the button at the end of the “Rule” setting to open expression editor:

Select “regExpTest” from the function list and click “insert” button. The first parameter is the Regular expressions. Below is an example of the Regular expressions for email verification:

(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

And, the second parameter is the string value (for this case, it’s the field value of the Office Email) that you want to do the verification.

Please refer below for the configured logic:

After completed, click “OK” to close the expression editor, and set the error message:

Click preview from the form designer to test and verify:

Refer the above steps and use the following Regular expressions to verify the phone number.

((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)

By following this guide, you can actually do any format validation of string value from List form, Approval form, or Public form etc.