Hola, tengo un texto y quiero reemplazar las ocurrencias de un texto por otro texto pero solo lo haga con palabras completas...
por ejemplo si en el texto esta "normalmente" y busco "normal" que no lo reemplaze porque es parte de una palabra...
Este es el codigo
Código PHP:
txtComp = ""
txtNuevoC = ""
Dim charsoptions(7) 'Fixed size array
charsoptions(0) = " "
charsoptions(1) = ","
charsoptions(2) = "."
charsoptions(3) = "'"
charsoptions(4) = ":"
charsoptions(5) = "("
charsoptions(6) = ")"
textoFuente = "Una frase normal que deberia funcionar normalmente"
textoNuevo = "<b>normal<b>"
textoViejo = "normal"
For Each item In charsoptions
txtComp = " " & textoViejo & item
txtNuevoC = " " & textoNuevo & item
if (InStr(1, textoFuente, txtComp, vbTextCompare) > 0) then
textoFuente = replace(textoFuente, txtComp, txtNuevoC, 1, -1, 1)
end if
txtComp = item & textoViejo & " "
txtNuevoC = item & textoNuevo & " "
if (InStr(1, textoFuente, txtComp, vbTextCompare) > 0) then
textoFuente = replace(textoFuente, txtComp, txtNuevoC, 1, -1, 1)
end if
Next
el tema es que me reemplaza normal en los 2 lugares.... no le hace caso al & " "
Alguna idea?
Gracias!