Re: regular expresion problem
- From: "Duca" <Ducarom@xxxxxxxxx>
- Date: 28 Sep 2006 05:26:03 -0700
Hi,
That is because the * is greedy. It will expand the match as far as it
can. Place a question mark after the * to make it lazy.
$prefec_test = "/(.*?[\+_]).*/";
MD wrote:
I am trying to figure out the regular expression problem
In case of $test1, I want to have @@@_ as a result
and for $test2 @@@+. How can i achieve this?
When testing $test1 variable always gives me @@@_@@_A
as a output string. I don't know why this happen either.
//$test1 = "@@@_@@_AAA";
$test2 = "@@@+@@+AAA";
$prefec_test = "/(.*[\+_]).*/";
if(preg_match_all($prefec_test, $test, $item)){
foreach($item[1] as $link)
{
echo $link;
}
}
Thanks in advance.
MD.
.
- References:
- regular expresion problem
- From: MD
- regular expresion problem
- Prev by Date: RE: [PHP] Convert UTF-8 to windows-874?
- Next by Date: Re: [PHP] strange errors from command line vs. web
- Previous by thread: regular expresion problem
- Next by thread: Re: [PHP] reading a remote directory
- Index(es):
Relevant Pages
|