Re: Regex Question

From: Date: Fri, 18 Aug 2000 16:33:25 +0000
Subject: Re: Regex Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12495@lists.php.net to get a copy of this message
gcat@bigpond.net.au ("Murray Shields") writes: > I have written a generic class that I am using in PHP3 to generate XML > statements. Everything is working perfectly except that I want to verify > that the variable names that are passed to the class are valid (according to > XML rules). > > Therefore I wish to pass a string of any length through a regex to check its > validity, but I have no idea how to do this. > > The rules are: > > The FIRST CHARACTER must be an underscore "_" or an alpha character (upper > or lower case, no numbers). > > ALL OTHER CHARACTERS must be alphanumeric OR underscore "_" OR minus "-" OR > period "." > > Can anyone help me to achieve this? ereg('^[_[:alpha:]][-_.[:alnum:]]*$', $xmlstring) -- Robin Vickery............................................... Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK Email: robin@planet-three.net Phone: +44 (0)794 670 6395

« previous php.general (#12495) next »