Ereg i | | |
Hi all
I've installed Apache 2.0.48 and PHP 4.3.4 on a
workstation running Linux, RedHat 9.0.
Let's consider the following piece of code:
$patt = "[0-9]{3}/[0-9]{6}";
if (ereg("^$patt$",$matricola))
echo "foo1";
else
echo "foo2";
Why the output is "foo1"? It should be "foo2". I 've tried the same
code
to another PHP & Apache installation (sorry but I do not remind the
version) on a windows box and it works fine.
What is the problem?
Thanks a lot in advance,
Alessandro | | | | re: Ereg i
Ok, Alessandro misses one line... the piece of code he refers is
$matr = "123/456789",
$patt = "[0-9]{3}/[0-9]{6}";
if (ereg("^$patt$",$matr))
echo "foo1";
else
echo "foo2";
Why the output is foo2?
Maurizio
Fiore Alessandro wrote:[color=blue]
> Hi all
>
> I've installed Apache 2.0.48 and PHP 4.3.4 on a
> workstation running Linux, RedHat 9.0.
>
> Let's consider the following piece of code:
>
> $patt = "[0-9]{3}/[0-9]{6}";
>
> if (ereg("^$patt$",$matricola))
> echo "foo1";
> else
> echo "foo2";
>
> Why the output is "foo1"? It should be "foo2". I 've tried the same
> code
> to another PHP & Apache installation (sorry but I do not remind the
> version) on a windows box and it works fine.
>
> What is the problem?
>
> Thanks a lot in advance,
> Alessandro[/color] | | | | re: Ereg i
*** Fiore Alessandro wrote/escribió (23 Jan 2004 00:53:53 -0800):[color=blue]
> if (ereg("^$patt$",$matricola))
> echo "foo1";
> else
> echo "foo2";
>
> Why the output is "foo1"? It should be "foo2".[/color]
What's the value of $matricula?
--
--
-- Álvaro G. Vicario - Burgos, Spain
-- | | | | re: Ereg i
Alvaro G Vicario wrote:[color=blue]
>
> What's the value of $matricula?
>[/color]
$mapricula="123/456789" | | | | re: Ereg i
Maurizio Palesi wrote:
[color=blue]
> $matr = "123/456789",
> $patt = "[0-9]{3}/[0-9]{6}";
>
> if (ereg("^$patt$",$matr))
> echo "foo1";
> else
> echo "foo2";
>
> Why the output is foo2?[/color]
It's not.
--
Jock | | | | re: Ereg i
*** Maurizio Palesi wrote/escribió (Fri, 23 Jan 2004 13:52:45 +0100):[color=blue]
> $mapricula="123/456789"[/color]
This code works for me (prints foo1):
<?
$matricola="123/456789";
$patt = "[0-9]{3}/[0-9]{6}";
if (ereg("^$patt$",$matricola))
echo "foo1";
else
echo "foo2";
?>
It isn't just a misspell of $matricola, is it?
--
--
-- Álvaro G. Vicario - Burgos, Spain
-- | | | | re: Ereg i
"Maurizio Palesi" <mpalesi@yahoo.it> wrote in message
news:buqnkd$ba6$1@newsfeed.cineca.it...[color=blue]
> Ok, Alessandro misses one line... the piece of code he refers is
>
> $matr = "123/456789",
> $patt = "[0-9]{3}/[0-9]{6}";
>
> if (ereg("^$patt$",$matr))
> echo "foo1";
> else
> echo "foo2";
>
> Why the output is foo2?[/color]
I get "foo1" when I run it (after correcting the comma on the first line to
a semicolon).
--
Peacenik | | | | re: Ereg i
Alvaro G Vicario <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in message news:<qt5zt2hcbnu$.1gojqwsqcvcu$.dlg@40tude.net>.. .
[color=blue]
>
> It isn't just a misspell of $matricola, is it?
>
> --[/color]
In my opinion the syntax is the problem. If you substitute the line
if (ereg("^$patt$",$matricola))
with
if (!ereg($patt,$matricola)) //Notice the ! before ereg
it does what you want, namely echoing "foo2".
Hope it is what you want,
Sebastiaan | | | | re: Ereg i
Should be foo1 the answer, what is wrong ???
Savut
"Fiore Alessandro" <fiorealessandro2000@yahoo.it> wrote in message news:b4e8a5e2.0401230053.4f37efed@posting.google.c om...[color=blue]
> Hi all
>
> I've installed Apache 2.0.48 and PHP 4.3.4 on a
> workstation running Linux, RedHat 9.0.
>
> Let's consider the following piece of code:
>
> $patt = "[0-9]{3}/[0-9]{6}";
>
> if (ereg("^$patt$",$matricola))
> echo "foo1";
> else
> echo "foo2";
>
> Why the output is "foo1"? It should be "foo2". I 've tried the same
> code
> to another PHP & Apache installation (sorry but I do not remind the
> version) on a windows box and it works fine.
>
> What is the problem?
>
> Thanks a lot in advance,
> Alessandro[/color] | | | | re: Ereg i
Alvaro G Vicario <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in message news:<qt5zt2hcbnu$.1gojqwsqcvcu$.dlg@40tude.net>.. .
[color=blue]
>
> It isn't just a misspell of $matricola, is it?
>
> --[/color]
In my opinion the syntax is wrong. If you substitute
if (ereg("^$patt$",$matricola))
with
if (!ereg($patt,$matricola)) //Notice the ! before ereg
it does what you want, namely echoing "foo2".
Hope this helps you out,
Sebastiaan |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|