
13/02/2003, 10:25
|
 | | | Fecha de Ingreso: enero-2002 Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 23 años, 3 meses Puntos: 5 | |
Prueba esto... te va a solucionar tus tres dudas...
<%
Function Cambia(ElTexto,LaBusqueda)
Dim Expresion, Patron, Cuenta
Set Expresion= New RegExp
Expresion.Pattern = ("((\S+\s+){0,5})("&LaBusqueda&"[\.,:;]*)((\s+\S+){0,5})")
Expresion.IgnoreCase = True
Expresion.Global = True
Set Matches=Expresion.Execute(ElTexto)
Cuenta=1
For Each Match in Matches
If Cuenta <9 Then
ElResultado = ElResultado& "..."& Match.Value & "... <br>"
End If
Cuenta=Cuenta+1
Next
Cambia = ElResultado
End Function
Function Negritas(ElTexto,LaBusqueda)
Dim Expresion
Set Expresion= New RegExp
Expresion.Pattern = ("("&LaBusqueda&"[\.,:;]*)")
Expresion.IgnoreCase = True
Expresion.Global = True
Set Matches=Expresion.Execute(ElTexto)
For Each Match in Matches
ElResultado = Expresion.Replace (ElTexto, "<b>$1</b>")
Next
Negritas = ElResultado
End Function
Dim Texto
Texto="El Tren: Muchos perros han caminado por este sendero triste y desolado, donde el tren pasa todas las mañanas haciendo un ruido insoportable que despierta hasta a don José, el simple sonido de el tren"
NuevoTexto=Cambia(Texto,"(tren|don)")
Response.write Negritas(NuevoTexto,"(tren|don)")
%>
__________________ Manoloweb |