p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Parsing strings


Message #1 by lausan@c... on Wed, 17 Apr 2002 19:16:46
Hi, 

I'm attempting to parse a string for any occurrences of values between 0-
9; is there any functions you could suggest for taking a string ie. 

Sara012Lee for a name field

and rejecting it because it is invalid input? I know the function for this 
would be 'instr' in ASP... 

Any help would be much appreciated asap.

Thanks,
Sandra
Message #2 by "Nikolai Devereaux" <yomama@u...> on Wed, 17 Apr 2002 11:17:34 -0700
> I'm attempting to parse a string for any occurrences of values between 0-
> 9; is there any functions you could suggest for taking a string ie. 
> 
> Sara012Lee for a name field


look at the regular expression match functions:

ereg()
  http://www.php.net/ereg

preg_match()
  http://www.php.net/preg_match


preg_match("/\d/", $name) will return true if there's a digit in $name.


take care,

nik


  Return to Index