|| apoc.text.regexGroupsByName - APOC 核心文档 - Neo4j 文档

apoc.text.regexGroupsByName

详情

语法

apoc.text.regexGroupsByName(text, regex)

描述

返回给定文本中与正则表达式匹配的所有组及其组名。

参数

名称

类型

描述

text

STRING

从中提取匹配项的文本。

regex

STRING

要匹配的正则表达式模式。

返回

LIST<MAP>

输出值为一个 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" } } ]

© . This site is unofficial and not affiliated with Neo4j, Inc.