正则表达式在 WSO2 中无法正常工作,但在 java 正则表达式测试器上给出了正确的响应
Regex is not working properly inside WSO2 but giving proper response on java regex tester
我有一个文本格式 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);
我想提取"payload"
下的所有内容
我看到你用空格包围了正则表达式,通过修剪那些来试试吧。
我有一个文本格式 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);
我想提取"payload"
下的所有内容我看到你用空格包围了正则表达式,通过修剪那些来试试吧。