J
julian_m
I want to delete whatever text between certain "tags" (note that I need
to remove html css comments as well as PHP comments)
so I have the following code
Sub EliminarCSSComments()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "/#*#/"
.Forward = True
.Wrap = wdFindStop 'para cuando se llega al final del documento
.MatchWildcards = True
Do While .Execute
oRng.Select
MsgBox "encontro"
oRng.Delete
Loop
End With
this works quite well if I wanted to delete text between /# and #/
see for instance this example
if I have
/# this should be removed #/
/# this should /be re#moved #/
both lines will be deleted.
but in the other hand, when I want to delete the text between /* and */
(wich is actually what I need), the code won't work as expected
for instance, if I have
/* this should be removed */
/* this sho/uld be r*emoved */
the result is
uld be r*emoved */
note that I tryied with the following text to search
.Text = "/" + Chr(42) + "*" + Chr(42) + "/"
'.Text = "/* */"
'.Text = "/*/"
'.Text = "/\*?{1,}\*/"
'.Text = "/**/"
'.Text = "</*>*<*/>"
'.Text = "/\*?{1,}\*/"
the problem seems to be that i need to search for asterisks(*), which
are seen by Word as wildcards...
any hint?
sdos - jm
to remove html css comments as well as PHP comments)
so I have the following code
Sub EliminarCSSComments()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "/#*#/"
.Forward = True
.Wrap = wdFindStop 'para cuando se llega al final del documento
.MatchWildcards = True
Do While .Execute
oRng.Select
MsgBox "encontro"
oRng.Delete
Loop
End With
this works quite well if I wanted to delete text between /# and #/
see for instance this example
if I have
/# this should be removed #/
/# this should /be re#moved #/
both lines will be deleted.
but in the other hand, when I want to delete the text between /* and */
(wich is actually what I need), the code won't work as expected
for instance, if I have
/* this should be removed */
/* this sho/uld be r*emoved */
the result is
uld be r*emoved */
note that I tryied with the following text to search
.Text = "/" + Chr(42) + "*" + Chr(42) + "/"
'.Text = "/* */"
'.Text = "/*/"
'.Text = "/\*?{1,}\*/"
'.Text = "/**/"
'.Text = "</*>*<*/>"
'.Text = "/\*?{1,}\*/"
the problem seems to be that i need to search for asterisks(*), which
are seen by Word as wildcards...
any hint?
sdos - jm