Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/05/2014, 10:33
gdasoft
 
Fecha de Ingreso: septiembre-2011
Mensajes: 116
Antigüedad: 12 años, 7 meses
Puntos: 8
Respuesta: Filtrar contenido String

Finalmente he resulto mi problema con una expresión regular. Por si alguien la necesita adjunto el código a continuación:

Código:
	Function filtra_string(byval str)

		Dim comienzo, strurl, colMatch,objMatch
		Set regEx = New RegExp
		regEx.Pattern = "((\+?34([ \t|\-|\.])?)?[9|6|7]((([ \t|\-|\.])?[0-9]{2}))([ \t|\-|\.])?[0-9]{2,3}([ \t|\-|\.])?[0-9]{2,3}([ \t|\-|\.])?[0-9]{0,3})"
    	regEx.Global = true
		set colMatch = regEx.execute (str)
		
		For each objMatch  in colMatch
			str = replace(str,objMatch.value,"[contenido bloqueado]")
		Next
		
		filtra_string = str
	 
	End Function
Con esta expresión puedo remplazar los teléfonos que empiezan con 34, 9, 7 y 6 y que están escritos en los siguientes formatos:
  • XXXXXXXXX
  • XXX.XXX.XXX
  • XXX XXX XXX
  • XXX.XX.XX.XX
  • XXX XX XX XX


Damos el tema como solucionado. Un saludo