从字符串中提取数据 [英] Extract data from a string

查看:93
本文介绍了从字符串中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿Goog早上,我的目标是从我从QRCode(使用我的Windows Phone应用程序扫描)收到的字符串中提取数据。 [注意。我创建了这个QRCode,如果你有一些提示来简化我的工作,请告诉我xD]

我从扫描中收到的字符串将是这样的:



TypeID:1730; DocumentID:10625289



显然我只需要数据来从网络服务中检索信息。

有一些方法可以在不使用10000000 string.split的情况下检索那部分数据?



和不,我不能写一个像这样的QRCode1730; 10625289 xD



感谢我的英语。

解决方案

  string  input =   TypeID:1730; DocumentID:10625289 ; 
List< string> values =
input.Split(' ;')。选择(x => x .Split(' :')。LastOrDefault())。ToList();
// 结果:1​​730,10625289< / string>


如果您的格式已修复,您可以这样做:



  var  str =   TypeID:1730; DocumentID:10625289; 
var parts = str.Split(' :'' ;');
var typeid = parts [ 1 ];
var documentid = parts [ 3 ];


Hey Goog morning, my goal is to extract data from a string that I receive from a QRCode(scanned with my Windows Phone application). [Note. I create this QRCode so if u have some tips to simplify my job, plz, tell me xD]
The string I receive from scan will be like this:

"TypeID:1730;DocumentID:10625289"

obviously I need only the data to retrieve information from a web service.
There is some method to retrieve that part of data without using 10000000 string.split?

and no, I cant write a QRCode like this "1730;10625289" xD

Thx and sorry for my English.

解决方案

string input ="TypeID:1730;DocumentID:10625289";
List<string> values =
       input.Split(';').Select(x=>x.Split(':').LastOrDefault()).ToList();
// result :1730, 10625289</string>


if your format is fixed you can do this:

var str = "TypeID:1730;DocumentID:10625289";
var parts = str.Split(':',';');
var typeid = parts[1];
var documentid = parts[3];


这篇关于从字符串中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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