如何在C#中使用StringSplitOptions和Regex获取特定值 [英] How to get paticular value using StringSplitOptions and Regex in C#

查看:120
本文介绍了如何在C#中使用StringSplitOptions和Regex获取特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中使用StringSplitOptions和Regex如何只获得44.66作为输出?



我得到正确的输出,其值结束如此(9.50,26.00)等..

但是当以这些值结束时(44.66,22.44,27.44)我没有得到预期的结果。



下一页Day Air(16.00 + 28.66 = 44.66)



请给我解决方案

解决方案

试试这个正则表达式,

(?< = [=])\\\ + \。\\\ {1,2} 


它会在等号后找到数字(在本例中为44.66),在

次日空气中有一个空格(16.00 + 28.66 = 44.66)


Using StringSplitOptions and Regex in C# how to get only 44.66 as output?

I got correct output where the value is ending like this (9.50 ,26.00) etc..
but when it comes to ending with these values (44.66,22.44,27.44 )am not getting the expected result.

Next Day Air (16.00 + 28.66 = 44.66)

Please give me solution

解决方案

Try this regex,

(?<=[=])\s\d+\.\d{1,2}


It will find the numbers (in this case 44.66) after the equal sign and one white space in

Next Day Air (16.00 + 28.66 = 44.66)


这篇关于如何在C#中使用StringSplitOptions和Regex获取特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆