On 29 July 2004 10:00, Jay wrote: > Hi! > > Can someone pelase help me to convert the following Vbscript code to > PHP, i am really sucky at Regular Expression: > ---------CODE VBSCRIPT--------------------- > Function IsValid(strData,blIncludeAlpha,blIncludeNumeric) > Dim regEx, retVal,strPtrn > Set regEx = New RegExp > If blIncludeAlpha Then > strPtrn="a-zA-Z" > End If > If blIncludeNumeric Then > strPtrn="0-9" > End If > if blIncludeAlpha and blIncludeNumeric Then > strPtrn="a-zA-Z0-9" > End if > regEx.Pattern = "^[" & strPtrn & "]+$" > IsValid= regEx.Test(strData) > End Function
Something like: function isValid($strData, $blIncludeAlpha, $blIncludeNumeric) { $strPattern = "/^[; if ($blIncludeAlpha): $strPattern .= "a-zA-Z"; endif; if ($blIncludeNumeric): $strPattern .= "0-9"; endif; $strPattern .= "]$/"; return preg_match($strPattern, $strData); } Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php