Re: ereg / regexp fun

From: Date: Wed, 16 Aug 2000 16:26:23 +0000
Subject: Re: ereg / regexp fun
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12070@lists.php.net to get a copy of this message
Try ereg("( *:[a-z] *)",$msg,$item); On Wed, 16 Aug 2000, Dieter Kneffel wrote: > Ok, this clarifies a bit. But what if there is no space in front > or after of my string but instead it is at the beginning or end > of the line > > example: > > I need something that matches these cases. > $msg = "command at the end of the line - :a"; > $msg = ":a command at the beginning "; > $msg = "command :a within my input"; > $msg = ":a"; > > On the other hand, it should NOT match something like this: > $msg = "hi:you!"; $msg =":aaabbb"; etc... > > Hope you see what I mean! > > - Dieter > > > Steven Werby schrieb: > > > Dieter Kneffel <data@wap4.com> wrote: > > > What is the correct regexp that matches a blank or the beginning of a > > > string? > > > What is the correct regexp that matches a blank or the end of a string? > > > > " " matches a space. [[:space:]] matches any whitespace character (including > > newline, etc.). [^ ] matches a space at the beginning. [ $] matches a space at > > the end of a string. But you don't want to match a space at the beginning or > > end. > > > > ereg(" :([a-z] {1}) ", $msg, $item) > > > > Then $item[1] will contain the letter you're looking for. > > > > > -- > 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.

« previous php.general (#12070) next »