此行在我的RTB中弹出,它会生成不同的字符,它会在几次中出现
" @ search_pointer&#34 ;:" 2b63f3fdae7f4d00a1273380938f6e8be9f858aa626c36212617a153046ebebf8f71295e81a0578b9a12b7683480728514336e6b66fcd0aa9a138c8867b9175caa504f55e1c02e29427cf0bc4512c546f9e5d60338cfff9a3fde3281140868bffa32ba9cf5d5192200d2b21c6dfb0c734ccb3b5a69f38532ae37937672722302",
我想通过查找 @search_pointer
这就是我所拥有的
Dim pattern As String = "("@search_pointer":.*",)"
RichTextBox1.Text = Regex.Replace(RichTextBox1.Text, pattern, String.Empty)
但很明显它会抛出错误,是的我是菜鸟
答案 0 :(得分:0)
我想你应该在字符串中使用双引号时使用""
:
Dim pattern As String = """@search_pointer"":.*,"
顺便说一句,检查你的模式。
一切顺利。
答案 1 :(得分:0)
检查以下示例:
Const Data As String = """tag1"":""tag1 value"", ""tagReplace"" : ""tagReplace value"", ""tag2"":""tag1 value"""
Private Function RegexReplace(ByRef searchPointer As String) As String
Dim pattern As String = "(""" & searchPointer & """\s*:.*""\s*,)"
Dim res As String = Regex.Replace(data, pattern, String.Empty)
Return res
End Function
注意我添加了\s*
来忽略空格。
用法:
RegexReplace("tagReplace")
它会从原始字符串中删除 tagReplace 标签。
我希望它有所帮助。