我的xml文件中有以下节点,它是另一个程序的导出。 我将不得不在我的应用程序中编辑xml文件,以便我可以正确地导入它。
节点:
<field name="memo" value="24-06-2004 Lorem ipsum dolor "sit" amit"/>
最终它必须变成这样的东西
<field name="memo" value="24-06-2004 Lorem ipsum dolor "sit" amit"/>
或者
<field name="memo" value="24-06-2004 Lorem ipsum dolor 'sit' amit"/>
答案 0 :(得分:0)
ResultString = Regex.Replace(SubjectString, _
"(?<= # Assert that this matches before the current position:" & chr(10) & _
" ^ # Start of string " & chr(10) & _
" [^""]*"" # Match any number of non-quotes, then one quote " & chr(10) & _
" (?>[^""]*"" # Match pairs of quotes, " & chr(10) & _
" [^""]*"" # optional non-quotes in-between " & chr(10) & _
" )* # any number of times. " & chr(10) & _
" [^""]* # Match any number of non-quotes " & chr(10) & _
") # End of lookbehind assertion " & chr(10) & _
""" # MATCH ONE QUOTE " & chr(10) & _
"(?! # Assert that the following cannot match here: " & chr(10) & _
" \s+ # Whitespace " & chr(10) & _
" \w+= # An identifier like value= " & chr(10) & _
"| # or " & chr(10) & _
" \s* # optional whitespace " & chr(10) & _
" [/?]? # followed by either / or ? or nothing " & chr(10) & _
" > # followed by > " & chr(10) & _
") # End of lookahead assertion. " & chr(10) & _
"| # OR do the same in the other direction: " & chr(10) & _
"(?<!\w+=)""(?=[^""]*""(?>[^""]*""[^""]*"")*[^""]*$)", _
""", RegexOptions.IgnorePatternWhitespace)