简体   繁体   English

如何在正则表达式中显示减号和加号

[英]How to show minus and plus sign in regex

I wrote a code that can take some values from the internet, and it works quite well. 我写了一个可以从互联网上获取一些价值的代码,并且效果很好。 The only drawback is that the operators + and - are not shown in my table. 唯一的缺点是运算符+-不在我的表中显示。 If for example I have a value type: +8 or -9 the regex me back 8 and 9, while I wish that the variable is mantained the + and - in front of the respective figures, such as +8 and -9.. The course is variable of type string as I do? 例如,如果我有一个值类型:+8或-9,则将正则表达式返回8和9,而我希望该变量在各个图的前面加上+和-,例如+8和-9。该课程是字符串类型的变量吗?

 .Differenza_reti = Val(Regex.Match(Content, "<td class=""number gd""\s*>[\+\-]?(\d+)</td>").Groups(1).ToString)

您需要将角色类放置在捕获组中以保留它们。

([+-]?\d+)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM