以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求一个字符串处理  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=119337)

--  作者:huangxueyao
--  发布时间:2018/5/23 9:18:00
--  求一个字符串处理
Dim str1 As String = "1111{2222},,,(A)(B)(C)sdsd sdsdsds"

Dim str2 As String = "()"

求根据str2找到str1中的A。


str2可能会变成{}

这时候结果就是2222了。

谢谢谢谢。

--  作者:有点甜
--  发布时间:2018/5/23 10:07:00
--  

写正则处理,如

 

 

Dim str1 As String = "1111{2222},,,(A)(B)(C)sdsd sdsdsds"
Dim str2 As String = "(?<=\\().+?(?=\\))"
Dim mc = System.Text.RegularExpressions.Regex.Matches(str1,str2)
For i As Integer = 0 To mc.count-1
    msgbox(mc(i).value)
Next



--  作者:huangxueyao
--  发布时间:2018/5/23 10:15:00
--  
谢谢谢谢