【发布时间】:2016-05-29 19:34:09
【问题描述】:
我的应用程序将 userdata.dll 的路径存储在一个字符串中。
我需要转换这个字符串:C:\Applications\User\userdata.dll
进入这个:C:\\Applications\\User\\userdata.dll
所有\ 都需要复制,与路径有多少\ 无关。
类似:
Dim defaultPath As String = "C:\Applications\User\userdata.dll"
' Regex
Dim r As Regex = New Regex( ... )
' This is the replacement string
Dim Replacement As String = " ... $1 ... "
' Replace the matched text in the InputText using the replacement pattern
Dim modifiedPath As String = r.Replace(defaultPath,Replacement)
对此有任何帮助吗?我正在尝试关注这个问题:
How to replace some part of this string with vb.net?
但不知道如何制作这个正则表达式...
【问题讨论】:
-
为什么需要正则表达式?
String.Replace工作正常:https://dotnetfiddle.net/vTnpIi