【发布时间】:2020-12-02 13:55:10
【问题描述】:
我想从与此模式匹配的字符串中获取子字符串:
:((?![{\[\-\d])([^,}]+))
match all string value.
例如:
altitude{altitudeValue:52420,altitudeConfidence:alt-002-00}}},
highFrequencyContainer:basicVehicleContainerHighFrequency:
{heading{headingValue:3601,headingConfidence:127},speed{speedValue:0,speedConfidence:127},
driveDirection:unavailable
我与此字符串上方的模式匹配:
:alt-002-00
:basicVehicleContainerHighFrequency:{heading{headingValue:3601
:unavailable
但我想要:
:alt-002-00
NO: **:3601** <--match from last ":" to end of previous match (is possible with regex?) only if is a
string.
YES: if was **:hello** <-match because is a string
:unavailable
我想从最后一个“:”匹配到上一个匹配的结尾(可以使用正则表达式吗?)。
如何改变我的模式规则? :((?![{\[\-\d])([^,}]+))
谢谢 问候
【问题讨论】:
-
如果冒号后面包含字母字符,你想匹配它吗(从技术上讲,'3601' 在这种情况下是一个字符串)?
-
是最后一个“:”之后的字符串
-
@Catanzaro 有没有解决方案?