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