When processing data, users often use regular expressions to describe certain string matching rules to filter text.
For example, the user needs to judge the "URL" text field. If the field is all numbers, it is marked as "Pure Number", otherwise it is marked as "Other", as shown in the following figure:
Use the REGEXP function to determine whether it is a pure number;
Then use the IF function to mark.
Sample data: scene document.xlsx
Upload sample data to FineBI.
Create a self-service dataset, select all the fields under the sample data, as shown in the following figure:
Add the "New column" step, name it "Pure Number", enter the formula: IF(REGEXP(URL,"\\d*")=1,"Pure Number","Other"), as shown in the figure below:
Note: The functions and fields in the formula box need to be selected by clicking the selection area on the left, and cannot be entered manually.
Formula description:
If the URL field is all numbers, it returns 1, otherwise it returns 0
"\d" means matching digits. If you want to use the "\" character, you need to add another backslash. So when the formula is regexp(string, "\d"), it will prompt that it is illegal, and it needs to be written as regexp(string, "\\d")
* It means match the preceding sub-expression zero or more times.
You can also use this formula: IF(REGEXP(URL,"^[0-9]*$")=1,"Pure number","Other"), as shown in the figure below:
If the URL field is all numbers, it returns 1, otherwise it returns 0.
"^" is the starting position of the matched input string.
"[0-9]*" match multiple digits, "[0-9]" match a single digit, "*" matches the preceding sub-expression zero or more times;
"$" Is the end position of the matched input string.
If the return value is 1, then output "pure number", otherwise output "other".
The regular expression is illustrated in the following figure:
See section 1.1 of this article for details.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy