Regex在WSO2中无法正常工作,但在Java regex测试器上给出了正确的响应

问题描述 投票:1回答:1

我有一个json为文本格式,我正在其中使用regex提取其中的一部分。我的正则表达式可以在在线Java正则表达式测试器上正常工作,但是相同的正则表达式在wso2流处理器中为我提供了null。

正则表达式:"(after)":("(\\"|[^"])*"|\[("(\\"|[^"])*"(,"(\\"|[^"])*")*)?\])

示例json:

{"type":"int64","optional":true,"field":"h"}],"optional":false,"name":"io.debezium.connector.mongo.Source","field":"source"},{"type":"string","optional":true,"field":"op"},{"type":"int64","optional":true}],"optional":false,"name":"topic1"},"payload":{"after":"{\"_id\": {\"$oid\": \"dsfsddsef\"},\"code\": \"42443242\",\"name\": \"NAME1\",\"desc\": \"DESCRIPTIONt\",\"transRefId\": \"43242FSFESFS\",\"origAmount\": 1000,\"amount\": 1000,\"currency\": \"USD\",\"updatedAt\": \"2019-12-07T18:27:10.764Z\",\"message\": \"\"}","patch":null,"source":{"version":"0.10.0.Final","connector":"mongodb","name":"ayapayuat","ts_ms":1575862490000,"snapshot":"true","db":"DB","collection":"COLL1","ord":1,"h":0},"op":"r","ts_ms":1575862492251}}

源配置:

@source(type='kafka',
        topic.list='demo',
        partition.no.list='0',
        threading.option='single.thread',
        group.id="group",
        bootstrap.servers='localhost:9092',
 @map(type='text',fail.on.missing.attribute='false',regex.A=""" "(after)":("(\\"|[^"])*"|\[("(\\"|[^"])*"(,"(\\"|[^"])*")*)?\]) """,
                @attributes(payload = 'A[2]')))
define stream transactionstream1(payload string);

我想提取“有效载荷”下的所有内容

regex wso2 regex-group siddhi wso2sp
1个回答
1
投票

我看到您已经用空格包围了正则表达式,请通过剪裁那些空格进行尝试。

© www.soinside.com 2019 - 2024. All rights reserved.