[英]Match strings not starting with dot or : character
I have the text below and I want to match the variable and the function types only. 我在下面输入文字,我只想匹配变量和函数类型。 So on the first line I want to match only the first "float", on the second line I want to match the first and the third "float" and then same for the "int". 因此,在第一行中,我只想匹配第一个“ float”,在第二行中,我想匹配第一个和第三个“ float”,然后对“ int”进行匹配。
Of course this is dynamic, basically I want to match with a regex strings that do not start with a dot or a : symbol. 当然,这是动态的,基本上我想与不以点或:符号开头的正则表达式字符串匹配。 I tried with negative lookahead but couldn't make it work 我尝试使用负前瞻,但无法正常工作
float JsValue.float
float JsValue:float(float testFloat)
int JsValue.int
int JsValue:int(int testInt)
The regex below captures everything which is not what I want. 下面的正则表达式捕获了我想要的所有内容。
\b(int|bool|float)\b
Thanks 谢谢
In the absence of lookbehind you can use negated character class: 在没有后视的情况下,您可以使用否定的字符类:
/(?:^|[^:.])\b(int|bool|float)\b/mg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.