Thank for your patient help!
But your suggestion like this “Doc.Range.Replace(New Regex(@”(?)"), “”, ReplaceOption)" to get the desired output, which actually can not get my desired output and can not meet my requirement.
so my issue is still pending, therefore, I strongly recommend to include this feature in the future version.
Your reply pay uselessness for my requirement, and I have to get the desired out by using :
For Each Parap As Global.Aspose.Words.Paragraph In doc.GetChildNodes(NodeType.Paragraph, True)
Index = Index + 1
Do
Ln = Parap.Range.Text.Length
Text = Parap.Range.Text
If (Text.Length = 1 Or Text.Trim.Length = 1 Or Text.Trim = Chr(13)) And Text <> "?" And Text <> "?" Then GoTo nextp
Runs = Parap.GetChildNodes(NodeType.Run, True)
Pos = Runs.Count
For i As Integer = 0 To Pos - 1
Run = Runs(i)
Text = Run.Text
If i = Pos - 1 Then Text = Text & Chr(13)
Pattern = "([\?\?\?\?\?])[\?\?\?\?\?]+"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1")
Pattern = "[\?\?\?\?\?]+"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then
Dim Matches = Regex.Matches(Text, Pattern)
Pos = Matches.Count
If Pos > 1 Then Text = Regex.Replace(Text, Pattern, "")
End If
Pattern = "^[\?\?\?\?\?]+"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "")
Pattern = "(\p{P})[\?\?\?\?\?]+\r"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1" & Chr(13))
Pattern = "([ ,。?:;‘’!""—……、]+|(-{2,})|([()]+)|([【】]+)|([\{\}]+)|([《》]+))[\?\?\?\?\?]+\r"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1" & Chr(13))
Pattern = "(\p{P})[\?\?\?\?\?]+"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1" & Chr(13))
Pattern = "[\?\?\?\?\?]+(\p{P})"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1" & Chr(13))
Pattern = "[\?\?\?\?\?]+([ ,。?:;‘’!""—……、]+|(-{2,})|([()]+)|([【】]+)|([\{\}]+)|([《》]+))"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1" & Chr(13))
Pattern = "([ ,。?:;‘’!""—……、]+|(-{2,})|([()]+)|([【】]+)|([\{\}]+)|([《》]+))[\?\?\?\?\?]+"
IsMatch = Regex.IsMatch(Text, Pattern)
If IsMatch Then Text = Regex.Replace(Text, Pattern, "$1" & Chr(13))
If i = Pos - 1 Then Text = Replace(Text, Chr(13), "")
On Error Resume Next
Run.Text = Text
If Err.Number Then
Run.Text = ""
End If
Next
My.Application.DoEvents()
Loop While Ln <> Parap.Range.Text.Length
My.Application.DoEvents()
nextp:
Next