How to use regex validation in text fields?

Estimated reading: 1 minute 72 views

Our text fields support regex validation, offering extensive flexibility to cater to various situations. By using these regular expressions, you can control the allowed input, ensuring data integrity and accuracy.

Here are some examples. Depending on your specific requirements, you may need to adjust these regex expressions accordingly:

  1. Email address:

    ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$

  2. URL:

    ^(https?|ftp):\\/\\/[^\\s\\/$.?#].[^\\s]*$

  3. Phone Number (with optional country code and dashes):

    ^\\+?\\d{1,3}?\\-?\\d{3,}[\\-]?\\d{4,}$

  4. Numeric Input (positive integers only):

    ^\\d+$

  5. Alphabetic Input (letters only, no spaces or special characters):

    ^[a-zA-Z]+$

  6. Alphanumeric Input (letters and numbers, no special characters):

    ^[a-zA-Z0-9]+$

Leave a Comment

Share this Doc

How to use regex validation in text fields?

Or copy link

CONTENTS