|
|
da: view-source:http://www.aspcode.it/articoli/articoli.asp?act1=show_art&idx=60
<%
Response.Write(LinkUrl(LinkEmail(stringa)))
%>
<%
Function LinkURL(stringa)
Dim objRegExp, strTemp
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "(\b(www\.|http\://)\S+\b)"
strTemp = objRegExp.replace(stringa, "<A HREF='http://$1' TARGET='_new'>$1</A>")
LinkURL = Replace(strTemp, "http://http://","http://")
Set objRegExp = Nothing
End Function
Function LinkEmail(stringa)
Dim objRegExp
Set objRegExp = New RegExp
objRegExp.Global = True
objRegExp.IgnoreCase = True
objRegExp.Pattern = "(\b[a-z._-]+@\S+\.[a-z]{2,3}\b)"
LinkEmail = objRegExp.replace(stringa, "<A HREF='mailto:$1' TARGET='_new'>$1</A>")
Set objRegExp = Nothing
End Function
%>
da: view-source:http://www.aspcode.it/articoli/articoli.asp?act1=show_art&idx=29
oRegExpr.Pattern = "\([0-9]{3}\)[0-9]{3}-[0-9]{4}"
<%
Function PhoneControl(stringa)
Dim objRegExpr
Set objRegExpr = New RegExp
objRegExpr.Pattern = "\([0-9]{3}\)[0-9]{3}-[0-9]{4}"
Dim colMatches
Set colMatches = objRegExpr.Execute(stringa)
PhoneControl = colMatches.Count
End Function
sCellulare = "(347)756-3412"
if PhoneControl(sCellulare) then
Response.Write("numero di telefono corretto")
else
Response.Write("numero di telefono non corretto")
end if
%>
da: http://www.aspcode.it/tips/tips.asp?act1=show_tip&idx=68
<%
Function GetNumber(stringa)
Dim objRegExp, strTemp
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "\d"
Set Matches = objRegExp.Execute(stringa)
For Each Match in Matches
strTemp = strTemp & Match.Value
Next
Set objRegExp = Nothing
GetNumber = strTemp
End Function
Response.Write(GetNumber("ccc567556hhg6"))
%>
da: http://www.aspcode.it/articoli/articoli.asp?act1=show_art&idx=31
<%
Function QuantitaSegno(colonna, segno)
Dim objRegExpr
Set objRegExpr = New RegExp
objRegExpr.Pattern = segno
objRegExpr.IgnoreCase = TRUE
objRegExpr.Global = TRUE
Dim colMatches
Set colMatches = objRegExpr.Execute(colonna)
QuantitaSegno = colMatches.Count
End Function
strColonna = “x12xx21x222x1”
strSegno = “X”
Response.Write(“Tot. di segn X: ”& QuantitaSegno(strColonna, strSegno))
%>
<%
Function IsCons(colonna, segno)
Dim objRegExpr
Set objRegExpr = New RegExp
objRegExpr.Pattern = "("&segno&segno&")"
objRegExpr.IgnoreCase = TRUE
objRegExpr.Global = FALSE
IsCons= objRegExpr.Test(colonna)
End Function
strColonna = “x12xx21x222x1”
strSegno = “X”
If IsCons(strColonna, strSegno) Then
Response.Write(“La colonna contiene segni ”& strSegno&” consecutivi.”)
Else
Response.Write(“La colonna non contiene segni ”& strSegno&” consecutivi.”)
End If
%>