Re: Preg_match_all problem

From: Date: Mon, 12 Apr 2004 16:04:46 +0000
Subject: Re: Preg_match_all problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-183167@lists.php.net to get a copy of this message
From: "Jeff McKeon" <jmckeon@telaurus.com> > Can anyone see why I'm getting this error message: > > "Warning: No ending delimiter '^' found in > C:\Inetpub\wwwMIS_DEV\import_mvs.inc.php on line 126" > > From this line: > > if(preg_match_all("^([00])?.*$",$called,$found)) Because you do not have an ending delimiter. In fact, you don't have a starting delimiter, either, but preg assumes you meant the ^ character to be your delimiter. This is explained in all of the examples in the manual, but you must surround your regular expression by a delimiter such as the / or # character. This is because you can include modifiers after the delimiters to further create your regex. if(preg_match_all("/^([00])?.*$",$called,$found)) Although I doubt that'll work like you want it since [00] matches a zero, or another zero. It only matches one character. > I basically have a phone bill that sometimes has the phone number > preceeded by "00" and sometimes not. > > When it has the "00" I want to trim it with the substring command. I wouldn't even use preg for this. Just use ltrim() or if(substr($called,0,2)=='00')... ---John Holmes...

« previous php.general (#183167) next »