在VB.NET中查找字符串 [英] Find a String in VB.NET
本文介绍了在VB.NET中查找字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从另一个字符串中提取一个字符串,用,,比如.csv
文件。
例如我有这个字符串:
String1 = 000,federico,00,439827HGH ,1233,FGB,0000,00,000
并且从该字符串我需要提取字符串federico和字符串FGB
然后分成另外两个字符串:
String2 =" federico"
String3 = FGB
如何在Visual Basic .NET中完成这项工作????
谢谢和最好的问候,>
Federico
Hi,
I need to extract a string from another string separated by "," like a .csv
file.
for example I have this string:
String1 = 000,federico,00,439827HGH,1233,FGB,0000,00,000
and from that string i need to extract string "federico" and string "FGB"
and separate then into another 2 strings:
String2 = "federico"
String3 = "FGB"
How this could be done in Visual Basic .NET ????
Thanks and best regards,
Federico
推荐答案
dim criteria as string ="(frederico)|(FGB)"
dim pattern as string ="(^"& criteria&",?)|(,?"& criterion&",?)|(,?"
& criteria&"
dim criteria as string = "(frederico)|(FGB)"
dim pattern as string = "(^" & criteria & ",?)|(,?" & criterion & ",?)|(,?"
& criterion & "
)"
dim regExp as new regEx(pattern)
dim match as匹配
dim yourString as string =" 000,federico,00,439827HGH,1233,FGB,0000,00,00 0"
regExp.Matches中的每场比赛(yourString)
console.writeline(match.value)
next
或其他什么东西。
hth,
史蒂夫
" Federico G. Babelis" < FE ****** @ gazum.com>在消息中写道
新闻:uC ************** @ TK2MSFTNGP10.phx.gbl ...
|
|
|我需要从另一个字符串中提取一个字符串,该字符串由,,比如
..csv
|文件。
|例如我有这个字符串:
|
| String1 = 000,federico,00,439827HGH,1233,FGB,0000,00,000
|
|从那个字符串我需要提取字符串federico和字符串FGB
|然后分成另外两个字符串:
|
| String2 =" federico"
| String3 =" FGB"
|
|如何在Visual Basic .NET中完成????
|
|谢谢和最好的问候,
|费德里科
|
|
)"
dim regExp as new regEx(pattern)
dim match as match
dim yourString as string = "000,federico,00,439827HGH,1233,FGB,0000,00,00 0"
for each match in regExp.Matches(yourString)
console.writeline(match.value)
next
or something therebouts.
hth,
steve
"Federico G. Babelis" <fe******@gazum.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
| Hi,
|
| I need to extract a string from another string separated by "," like a
..csv
| file.
| for example I have this string:
|
| String1 = 000,federico,00,439827HGH,1233,FGB,0000,00,000
|
| and from that string i need to extract string "federico" and string "FGB"
| and separate then into another 2 strings:
|
| String2 = "federico"
| String3 = "FGB"
|
| How this could be done in Visual Basic .NET ????
|
| Thanks and best regards,
| Federico
|
|
史蒂夫:
谢谢,但是,也许我以错误的方式解释这一点,因为字符串
总是会有所不同,并且在任何时候都不知道它的价值,唯一的
将知道关于,的立场。人物。
任何想法?
再次感谢...
Federico
>
" steve" < a@b.com>在消息中写道
news:10 ************* @ corp.supernews.com ...
Steve:
Thanks but, maybe I explain this in the wrong way, because the strings
always will be different and will don''t know its value at any time, the only
thing that will know is the position regarding the "," character.
any idea ?
Thanks again...
Federico
"steve" <a@b.com> wrote in message
news:10*************@corp.supernews.com...
dim criteria as string =" ;(frederico)|(FGB)"
dim pattern as string ="(^"& criteria&",?)|(,?"& criterion&
",?)|(,?"& criterion&"
dim criteria as string = "(frederico)|(FGB)"
dim pattern as string = "(^" & criteria & ",?)|(,?" & criterion & ",?)|(,?" & criterion & "
这篇关于在VB.NET中查找字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文