[英]Get second occurrence from a string
string str="Customer was charged £10,000 and £11,000 for the same service in June and July respectively".
I want to fetch the second amount from the string. 我想从字符串中获取第二笔金额。
I am using below expression but it is only giving the first value that is £10,000. 我使用下面的表达式,但它只给出了10,000英镑的第一个价值。
string m = Regex.Match(str, @"\£[^ ]+").Value.ToString();
Please let me know how can i skip the first one and pick directly the second value. 请让我知道如何跳过第一个值并直接选择第二个值。
use Matches()
to get all possible results and Skip(1)
to skip the first 使用
Matches()
获得所有可能的结果,并使用Skip(1)
跳过第一个
string str = "Customer was charged £10,000 and £11,000 for the same service in June and July respectively";
string m = Regex.Matches(str, @"\£[^ ]+").Cast<Match>().Skip(1).FirstOrDefault()?.Value?.ToString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.