Re: ereg / regexp fun
| From: | Hans H. Anderson | Date: | Wed, 16 Aug 2000 15:17:17 +0000 |
| Subject: | Re: ereg / regexp fun | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12048@lists.php.net to get a copy of this message | ||
Dieter,
There are limits. This won't work either:
$hans = "index.";
print "$hanshtml";
even though I'm trying to get "index.html", that's not setup well. PHP
thinks I'm trying to print the variable $hanshtml, but ends up printing
nothing.
Similarly, Steven's regex will work for you (I don't think you need the
{1}, though), but you have to make sure you are sending it a string it can
work with. If you are trying to match three consecutive matches, like
:a:b:c, then you are also going to end up matching name:hans or some other
accident. You can either eliminate those accidents (make sure the only
colons followed by a lower case letter are the variables) or do
this:
$string = ":a";
$string = ' '. $string . ' '; // ensure leading and trailing space
And make sure that each 'variable' is separated by something other than
'a-z'
Hans
On Wed, 16 Aug 2000, Dieter Kneffel wrote:
>
> Steven Werby wrote:
>
> > ereg(" :([a-z] {1}) ", $msg, $item)
>
> Well, almost.
> But this means, there has to be a blank at both ends. So something
> like $msg = ":a"; still doesn't work
>
> tnx anyway...
>
> dk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>
Hans Anderson ~ me@hansanderson.com
PO Box 426, Missoula, MT 59806 | PHP, Search Engines, SQL
(800)397-9116 / (406)549-6524 | Databases, Flash Multimedia,
http://www.hansanderson.com | Killer Audio Production,
http://www.goofiness.com | Minty Fresh Breath.