Re: Regular Expressions?

From: Date: Fri, 20 Apr 2001 06:49:26 +0000
Subject: Re: Regular Expressions?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-49508@lists.php.net to get a copy of this message
Hi Jason, @ 2:40:34 AM on 4/20/2001, Jason Caldwell wrote: > I'm a little lost as to the exact function of the following: > ^ and $ ^ beginning of a string. $ end of a string. > I noticed in the example below... that when I added the $ to the end of the > expression, I wasn't able anymore to put a non-alphanumeric character in the > end, for example (without the $) > I was able to enter the following and get a 'match' > aaa.a! <-- matched Matches the expression with one or more alnum's before the \. and one or more after the \. ! is [:punct:] > aaa.! <-- no match No alnum after the \. If you want to match that, replace the + with a * > after I put the $ on the end > aaa.a! <-- no match Doesn't match the expression \.[[:alnum:]]+$ > aaa.aa32 <-- match... > So, am I to understand that the ^ and $ are used to tell the expression that > it *must* match what the expression expects? Yep; more precisely, ^[something]$ matches the whole string. -Brian -- PGP is spoken here: 0xE4D0C7C8 Please, DO NOT carbon copy me on list replies.

« previous php.general (#49508) next »