
31/05/2007, 14:31
|
 | Moderador | | Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 23 años, 3 meses Puntos: 98 | |
Re: Problema con expresiones regulares Update: http://support.microsoft.com/kb/818802
Código:
Function TestRegExp(myPattern, myString)
'Create objects.
Dim objRegExp
Dim objMatch
Dim colMatches
Dim RetStr
' Create a regular expression object.
Set objRegExp = New RegExp
'Set the pattern by using the Pattern property.
objRegExp.Pattern = myPattern
' Set Case Insensitivity.
objRegExp.IgnoreCase = True
'Set global applicability.
objRegExp.Global = True
'Test whether the String can be compared.
If (objRegExp.Test(myString) = True) Then
'Get the matches.
Set colMatches = objRegExp.Execute(myString) ' Execute search.
For Each objMatch In colMatches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & objMatch.FirstIndex & ". Match Value is '"
RetStr = RetStr & objMatch.Value & "'." & vbCrLf
Next
Else
RetStr = "String Matching Failed"
End If
TestRegExp = RetStr
End Function
Response.Write(TestRegExp("([0-9]{8},|[0-9]{8}[/[0-9]*]*)", "12345678,12345678/1/2, 21234554/24/26/21"))
Salud
__________________ "El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway |