您的当前位置:首页正文

VB.NET中使用正则表达式

来源:化拓教育网
VB.NET中使⽤正则表达式

fderStr2 = System.Text.RegularExpressions.Regex.Replace(fderStr1, \"^([^s]*)\\(\", \"\")

其实只要⼀句就可以了,表达式为替换( 括号之前的所有东西

fderStr2 = System.Text.RegularExpressions.Regex.Replace(fderStr1, \"^([^s]*)\\(\关于正则表达式的使⽤

Dim xRegex As New System.Text.RegularExpressions.Regex(1)括号⾥的1 改成 0 也⼀样的,⽬前不知道是什么作⽤,但必须得填fderStr2 = xRegex.Replace(fderStr1, \"^([^s]*)\\(\

替换三个参数,

Dim xRegex As New System.Text.RegularExpressions.Regex(1)fderStr2 = xRegex.Replace(fderStr1, \"^([^s]*)\\(\会报警告,改成下⾯的,不会报

fderStr2 = System.Text.RegularExpressions.Regex.Replace(fderStr1, \"^([^s]*)\\(\

If Label5.Text <> \"Label5\" And Label6.Text <> \"\" And Label5.Text <> \"\" Then Dim xRegex As New System.Text.RegularExpressions.Regex(1)

Dim fder1Path, fder2Path, fder3Path, fderStr1, fderStr2, fderStr3, fderStr4 As String fder1Path = Trim(Label5.Text) fder2Path = Trim(Label6.Text) fder3Path = Trim(Label7.Text)

Dim dir As New System.IO.DirectoryInfo(fder1Path)

For Each d As System.IO.DirectoryInfo In dir.GetDirectories ' Dim finfo As New System.IO.FileInfo(d.Name)

'If (finfo.Attributes And System.IO.FileAttributes.Hidden) <> System.IO.FileAttributes.Hidden Then 'End If

fderStr1 = d.Name

' fderStr2 = System.Text.RegularExpressions.Regex(\"^([^s]*)\\(\ fderStr2 = xRegex.Replace(fderStr1, \"^([^s]*)\\(\", \"\") MsgBox(fderStr2) Next Else

MsgBox(\"请 选择 三个⽂件夹\", MsgBoxStyle.Exclamation, \"提⽰\") End If

因篇幅问题不能全部显示,请点此查看更多更全内容