Steve,
Also A VFP solution using VB Scripting solution as programmatic classes
below
Dave Crozier
***********
* Classes to validate email addresses
Local oReg
oReg_Email=CreateObject("clsEmailRegularExpression")
oReg_HTTP=CreateObject("clsHTTPRegularExpression")
Clear
? oReg_Email.Test("[EMAIL PROTECTED]") && OK
? oReg_Email.Test("[EMAIL PROTECTED] software.co.uk") && Invalid
*
? oReg_HTTP.Test("www.replacement-software.co.uk") && Invalid
? oReg_HTTP.Test("http://www.replacement-software.co.uk ") &&OK
*
Return
Define Class clsAbstractRegularExpression As Relation
sName = "clsAbstractRegularExpression"
sPattern = ""
bIgnoreCase = .T.
bGlobal = .T.
sRegExpClass = "VBScript.RegExp"
oRegExp = Null
Protected sName, sPattern, bIgnoreCase, bGlobal, ;
sRegExpClass, oRegExp
Protected Procedure Init()
LOCAL llRetVal
llRetVal = DODEFAULT()
If llRetVal
This.oRegExp = CreateObject(This.sRegExpClass)
With This.oRegExp
.Pattern = This.sPattern
.IgnoreCase = This.bIgnoreCase
.Global = This.bGlobal
EndWith
EndIf
EndProc
Protected Procedure GarbageCollect
This.bGarbageCollected = .T.
This.oRegExp = Null
*
EndProc
Procedure Test(tsSearchString)
LOCAL lbRetVal
lbRetVal = This.oRegExp.Test(tsSearchString)
Return lbRetVal
*
EndProc
Procedure Replace(tsSearchString, tsReplaceString)
LOCAL lbRetVal
lbRetVal = This.oRegExp.Replace(tsSearchString, tsReplaceString)
Return lbRetVal
*
EndProc
Procedure Execute(tsSearchString)
LOCAL loMatches
lomatches = This.oRegExp.Test(tsSearchString)
Return loMatches
EndProc
*
EndDefine
*-- Matches URLs in the form of http://URL or https://URL
Define Class clsHTTPRegularExpression As clsAbstractRegularExpression
sName= "clsHTTPRegularExpression"
sPattern= "((http(s?)\://){1}\S+)"
bIgnoreCase= .T.
bGlobal= .T.
Protected sName, sPattern, bIgnoreCase, bGlobal, ;
sRegExpClass, oRegExp
*
EndDefine
*-- Matches Emails the form of [EMAIL PROTECTED]
Define Class clsEmailRegularExpression As clsAbstractRegularExpression
sName="clsHTTPRegularExpression"
sPattern= "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]" ;
+"@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
bIgnoreCase= .T.
bGlobal= .T.
Protected sName, sPattern, bIgnoreCase, bGlobal, ;
sRegExpClass, oRegExp
*
EndDefine
*
* End of Coding
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.6.6/794 - Release Date: 08/05/2007
14:23
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.