如何在.net中获取特定字符串 [英] how to get particular string in .net
问题描述
嗨
我有以下字符串
string1 =" provider = pervasive oledb;数据源=试验; location = mycomputer"
现在我想要获取字符串
string2 = test(即=我的数据源中的任何内容=)
>
和string3 = mycomputer(即=我的位置= =)
string1中的字符串也没有固定
这是windows应用程序在vb.net
任何人都可以帮我找到解决方案...
提前感谢....
hi
i have following string
string1="provider=pervasive oledb; datasource=test; location=mycomputer"
now i want to fetch the string
string2=test (i.e.= whatever in my datasource=)
and string3=mycomputer (i.e.=whatever in my location=)
also the string in string1 is not fixed
this is windows application in vb.net
Can anyone help me in finding the solution...
thanks in advance....
推荐答案
使用 String.Split()方法并将字符串拆分为;。这将为您提供一系列字符串,您可以随意使用它们。
-Frinny
Use the String.Split() method and split the string on ";". This will give you an array of Strings and you can do with them as you please.
-Frinny
或者您可以使用正则表达式:
or you could use regular expressions:
或者您可以使用正则表达式:
or you could use regular expressions:
我不知道为什么我总是忘记正则表达式。
它们非常方便,尤其是字符串。
感谢Balabaster:)
I don''t know why I always forget about regular expressions.
They are very handy especially with Strings.
Thanks Balabaster :)
这篇关于如何在.net中获取特定字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!