Quote:
Originally Posted by Guessed
First, do a wildcard search for
\(* [0-9]{4}*\)
Replace with nothing
|
Dear Andrew,
Thanks for your comment
It's ok may be, but it has some bugs
if apply it to this text
However, antibiotics have been used to
(2016) kill harmful bacteria but inappropriate use of these materials enabled bacterial species to increase resistance to them which results in the emergence of resistance towards bacteria (Mmola et al., 2016).
Using silver nanoparticles (AgNPs) could be a good alternative to antibiotics (Huh & Kwon, 2011;Ahluwalia et al., 2014; Allafchian et al., 2016; Bagherzade et al., 2017; Bar et al., 2009; Hsieh et al., 2007; Ibrahim, 2015).
The result
However, antibiotics have been used to kill harmful bacteria but inappropriate use of these materials enabled bacterial species to increase resistance to them which results in the emergence of resistance towards bacteria. Using silver nanoparticles.
Main bugs:
(2016) has been removed
(AgNPs) also has been removed
the text after (AgNPs) has been removed to the end of the paragraph
all above items must be maintained
Also, I noted for some text, it removes the text between two parentheses, in addition to the parentheses themselves (the same case when searching for et al).
Dear Andrew, I suggest merging the search for
number and et al in the same condition (also has a bug, in the case of (Huh & Kwon, 2011)).
Or as I noted for all parenthesis that I want to remove, they share this format, comma space four digits ", 1234" ----> (Huh & Kwon, 2011).
So searching for this format, I think it will produce better results.
Here is my code
Code:
Sub RemoveRefParenthesis()
' code applied to selected text
Dim oRng As range
If Len(Selection.range) = 0 Then
MsgBox "Select the text first", vbCritical
Exit Sub
End If
Set oRng = Selection.range
With oRng.Find
.Text = "\(*[0-9]{4}*\)"
' .Text = "\(, [0-9]{4}*\)"
' .Text = "\(*et al*\)"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub
Thanks