is there any possible way to get a global solution of the regex.pattern for xml type of text?
that way i"ll get rid of the replace function and shell use the regex.
The trouble is to analyze the < > coming in order or not..
Also replacing reserved chars as ' & and so on.
here is the code
'handling special chars functions
Friend Function ReplaceSpecChars(ByVal str As String) As String
Dim arrLessThan As New Collection
Dim arrGreaterThan As New Collection
If Not IsDBNull(str) Then
str = CStr(str)
If Len(str) > 0 Then
str = Replace(str, "&", "&")
str = Replace(str, "'", "'")
str = Replace(str, """", """)
arrLessThan = FindLocationOfChar("<", str)
arrGreaterThan = FindLocationOfChar(">", str)
str = ChangeGreaterLess(arrLessThan, arrGreaterThan, str)
str = Replace(str, Chr(13), "chr(13)")
str = Replace(str, Chr(10), "chr(10)")
End If
Return str
Else
Return ""
End If
End Function
Friend Function ChangeGreaterLess(ByVal lh As Collection, ByVal gr As Collection, ByVal str As String) As String
For i As Integer = 0 To lh.Count
If CInt(lh.Item(i)) > CInt(gr.Item(i)) Then
str = Replace(str, "<", "<") /////////problems////
End If
Next
str = Replace(str, ">", ">")
End Function
Friend Function FindLocationOfChar(ByVal chr As Char, ByVal str As String) As Collection
Dim arr As New Collection
For i As Integer = 1 To str.Length() - 1
If str.ToCharArray(i, 1) = chr Then
arr.Add(i)
End If
Next
Return arr
End Function
got trouble at problem mark
that's a standart xml with different tags i want to analyse..