我用Python编写了一个程序,现在我想将其转移到vb.net。但是我在使用 vb.net 正则表达式时遇到了一些困难......有人可以帮助我吗?
这是我的 Python 正则表达式:
id = re.search('(?<=watch\?v\=)[\w|-]+|(?<=/v/)[\w|-]+', src)
id = id.group(0)
t = re.search('(?<=\&t\=)[\w|-]+', src)
t = t.group()
它应该找到 ?v=Value&SomeOtherContent 和 &t=Value&SomeOtherContent 的值
谢谢
最佳答案
解析查询字符串的一种简单方法是使用 NameValueCollection
,使用 HttpUtility.ParseQueryString
方法。这也负责编码。
例如:
NameValueCollection parameters = HttpUtility.ParseQueryString("?var1=1&var2=2");
关于Python 正则表达式到 VB.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2723485/