Re: Searching a string

From: Date: Mon, 10 Jul 2000 14:10:40 +0000
Subject: Re: Searching a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5721@lists.php.net to get a copy of this message
ereg() and eregi() allow you to use regular expressions on strings. For example, if you wanted to search a line in your e-mail messages for the "To:" header, you would say something like if (ereg ("To:", $line)) { ... } and likewise for the other headers. The first parameter is the regular expression you want to use, and the second parameter is the string you are searching. I would suggest learning to read and form regular expressions since they are a very very very powerful tool for parsing text, as you are wanting to do. Hope this helps. Stephen. "J. Geusebroek" wrote: > > Hi there, > > I have the following problem / question: > > I'm trying to parse an email message using PHP. The email message always > contains some > static text for example: > > From: "Mr.X" <Mr.X@linux.org> > To: <i@dont.know> > Subject: qweqwe > > I have the complete file spit in lines in my PHP script. How can i extract > the values > behind From: To: and Subject: ? I was thinking about using 'ereg' to > identify the lines > and then use 'substr' to get the rest of the string. > > I don't really understand how to use the ereg function, can someone please > help? > > Thanks a lot, > > Jeroen Geusebroek -- Stephen Hui, ARL:UT, Austin, Texas Computer Terms: Programmer - A red-eyed, mumbling mammal capable of conversing with inanimate objects.

« previous php.general (#5721) next »