Introduction to Regular Expression
What is a regular expression
Regular expressions provide a powerful, flexible and efficient way to validate text content, ensuring that the content complies with predefined formats or patterns.
Use Case
In the customer information worksheet, it is often necessary to record a customer's WeChat ID, which cannot contain Chinese characters, only letters and numbers. Therefore, we can use regular expressions to restrict the input content.
1. Configure a regular expression
Regular expressions are typically applied to text fields and file fields (used to restrict file names). When setting properties for these fields, you can start configuring regular expressions by checking the "Restrict input format" option.
In the configuration page, a series of commonly used regular expressions is usually provided on the left for users to choose from. You can simply click on one to apply it directly to the current field. Additionally, if you have specific requirements, you can also modify the provided expressions to create custom regular expressions (please note that custom expressions usually cannot be saved to the list of commonly used expressions on the left).
Here, we only need to select the "Letter and number" expression on the left. After configuration is complete, click the "Confirm" button to save the settings and save the entire form to ensure that the changes take effect.
Caption
A field supports multiple expressions, with captions for quick identification of the expressions.
Regular expression
Edit the expression you need here. The regular expression cannot start with a space, so please ensure the accuracy of the expression.
Prompt for errors
When the content entered by the user does not meet the format requirements of the regular expression you have set, the system will automatically display an error prompt to the user.
Test
Enter a test content to verify if the regular expression and error prompt you have set meet actual requirements.
2. Filters
Each expression can be individually configured with filter conditions. The expression will only take effect when these conditions are met. If no filter conditions are configured for an expression, the expression will always be in effect.
3. Multiple Expressions
In a single field, you can create up to 5 expressions, and these expressions can be sorted among each other.
When dealing with fields containing multiple expressions, the system will validate the entered content one by one in the order of effective expressions until it encounters the first expression that is not satisfied, prompting the corresponding error message. The subsequent expressions will not be validated.
The conditions for the effectiveness of expressions are as follows:
If an expression is not configured with a filter, the expression will always be in effect.
If an expression is configured with a filter, the expression will only take effect when the filter conditions are met.
To help you learn and master regular expressions better, we recommend you visit the following website: https://www.runoob.com/regexp/regexp-tutorial.html.
Have questions about this article? Send us feedback