匹配正负小数?
我试图使用正则表达式匹配两个标签之间的正数和负数,正数返回正常,但负数不匹配。我正在使用:
string value8 = (",\"lng\":\"(([^\"\\\\]|-\\\\.)*)\",");
Match[] lng = Regex.Matches(Text, value8)
来匹配
"lng":"-104.845275878905880"
或相似,它可以是正数或负数。当正数时,它与数字匹配,但当负数时,则没有匹配项。
I'm trying to match positive and negative numbers inbetween two tags using regex, the positive numbers return fine but the negative ones do not match. I am using:
string value8 = (",\"lng\":\"(([^\"\\\\]|-\\\\.)*)\",");
Match[] lng = Regex.Matches(Text, value8)
to match against
"lng":"-104.845275878905880"
or similar, it can be positive or negative. When positive it matches the number but when negative, there are no matches.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非我遗漏了一些东西,否则你的正则表达式看起来比它需要的要复杂一些。您应该能够使用类似这样的内容:
顺便说一句,我删除了表达式开头的逗号,因为这会阻止此模式与您的示例数据匹配。
Unless I'm missing something, your regex looks a little more complex than it needs to be. You should be able to use something like this:
Incidentally, I removed the comma at the beginning of your expression, as that would prevent this pattern from matching your sample data.