Re: ereg / regexp fun

From: Date: Wed, 16 Aug 2000 17:08:11 +0000
Subject: Re: ereg / regexp fun
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-12063@lists.php.net to get a copy of this message
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. >

« previous php.general (#12063) next »