Description:
Match members in a string sequence with the regular expression.
Syntax:
A.regex(rs,Fi) |
If no extracting item is specified in rs, match field Fi of the string with rs based on data type. Then return the new record sequence after record sequence A is filtered. Use the current record to match with rs if omitting Fi |
A.regex(rs;Fi,…) |
If one or more extracting items are specified in rs, split the string members of sequence A according to them, and return the results as a table sequence whose fields are Fi |
Note:
The function matches the members of string type in the sequence A with the regular expression rs.
The results will be merged into a table sequence whose fields are Fi for returning.
Parameter:
A |
A sequence or a record sequence whose members are strings |
rs |
Regular expressions. The extracting items are specified sub-regular expressions which are separated from each other by separators and each is surrounded with the parentheses. They will match the fields in sequence. For example, "(.*),(a.*)" are two extracting items separated by a comma |
Fi |
Resulting field names of string type |
Option:
@c |
Case insensitive |
@u |
Use Unicode to match |
Return value:
A table sequence
Example:
|
A |
|
1 |
=demo.query("select NAME,SURNAME from EMPLOYEE") |
|
2 |
=A1.(~.array().concat@c()) |
Convert to a sequence of strings. |
3 |
=A2.regex("A.*") |
By default, use current record to match with rs if omitting Fi. |
4 |
=A2.regex("(V.*),(.*)";name,surname) |
Match members of A2 with the regular expressions and return a table sequence. |
5 |
=file("D:\\a.txt").import@ts() |
|
6 |
=A5.(#1).regex@c("(.*),(a.*)";id,name) |
Match names that start with a or A. |
7 |
=file("D:\\c.txt":"UTF-8").import@ts() |
|
8 |
=A7.(~.array().concat@c()) |
|
9 |
=A8.regex@u("(\\u9500\\u552e\\u90e8),(.*)";SalesDep,EmployeeName) |
Use Unicode to match the Sales Dep. |
10 |
=A1.regex("V.*",NAME) |
Without an extracting item, match the regular expression rs with the string type Fi field. |
Related function: