我想阅读此文件中的特定文字' config.txt'
action url: "item1"
referer: "item2"
post data: 'item3'
我的代码:
dim item1 as string
dim item2 as string
dim item3 as string
textbox1.text = (item1)
textbox2.text = (item2)
textbox3.text = (item3)
我希望item1 to = action url: "(*.?)" CaptureGroup(1).Value
从文本文件中读取,依此类推,使用item2和item3
答案 0 :(得分:0)
如果文件总是这种格式,也许你不需要正则表达式? : -
Dim FileContent As String = "action url: .... etc"
Dim DivArr As Char() = {Chr(34), Chr(39)}
'split into segments using single & double quotes as separators
Dim parts() As String = FileContent.Split(DivArr)
textbox1.text = parts(1)
textbox2.text = parts(3)
textbox3.text = parts(5)
答案 1 :(得分:-1)
public static int integer;
例如
Imports System.Text.RegularExpressions
Private Function match(regex As String, html As String, Optional i As Integer = 1) As String
Return New Regex(regex, RegexOptions.Multiline).Match(html).Groups(i).Value.Trim()
End Function