apoc.text.regexGroupsByName
语法 |
|
||
描述 |
返回给定文本中与正则表达式匹配的所有组及其组名。 |
||
参数 |
名称 |
类型 |
描述 |
|
|
从中提取匹配项的文本。 |
|
|
|
要匹配的正则表达式模式。 |
|
返回 |
|
||
输出值为一个 LIST<MAP>,其中包含一个 group 字段(其值为完整匹配项),以及一个 matches 字段(该字段本身是一个 MAP,其中包含每个组名及其对应值)。
{
group: <groupMatched>,
matches: {
<groupName>: <match>, ...
}
}
使用示例
RETURN apoc.text.regexGroupsByName(
'abc <link xxx1>yyy1</link> def <link xxx2>yyy2</link>',
'<link (?<firstPart>\\w+)>(?<secondPart>\\w+)</link>'
) AS output;
| 输出 |
|---|
[{ "group": "<link xxx1>yyy1</link>", "matches" : {"firstPart": "xxx1", "secondPart": "yyy1"}}, {"group": <link xxx2>yyy2</link>", "matches" : { "firstPart": "xxx2", "secondPart": "yyy2"}}] |
RETURN apoc.text.regexGroups(
'Michael: 1234\nJennifer: 5678',
'(?<name>\\w+): (?<id>\\d+)'
) AS output;
| 输出 |
|---|
[ { "group": "Michael: 1234", "matches": { "name": "Michael", "id": "1234" }, { "group": "Jennifer: 5678", "matches": { "name": "Jennifer", "id": "5678" } } ] |