开发者

Get value between 2 spaces

开发者 https://www.devze.com 2023-02-09 15:53 出处:网络
Given the string value: ?*8 100 0 I\'d like the value between the two spaces 开发者_开发百科(100).

Given the string value:

?*8 100 0

I'd like the value between the two spaces 开发者_开发百科(100).

How is it possible to get that value?


var value = myString.Split(' ')[1];

and if you'd really like to use Regex

var value = Regex.Match(myString, @" [^ ]+").Value.Trim();

but it adds quite a bit of overhead. Since you said the value is always a number

var value = int.Parse(Regex.Match(myString, @" \d+").Value);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号