[PHP] Regular Expressions (PCRE library)

2002-08-03 Thread Jürgen

Hello!

It´s driving me nuts, am in the middle of reading Mastering Regular
Expressions (O'Reilly), and because i like to learn whilst doing, well, you
can picture the rest.

Anybody please tell me why the following is not working

$test = Hello, end why is not workin, END.;

//before
echo $test .  br;

//Finds beginning of a line, followed by e or E, and replaces it with A. At
least it should do it, but it doesn't ?
$tes = preg_replace(/^[eE]/, A,  $test);

//after
echo $tes;

Now i know damn well that this is a real simple example, and thus failing
here already makes me feel quite frustrated.

Any help or explanations as to what is wrong in the above example along with
a little explanation would be greatly appreciated!

Thanks a lot in advance for your time reading.

Best regards from Vienna,
Jürgen



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Regular Expressions (PCRE library)

2002-08-03 Thread Jason Wong

On Sunday 04 August 2002 01:44, Jürgen wrote:

 Anybody please tell me why the following is not working

 $test = Hello, end why is not workin, END.;

 //before
 echo $test .  br;

 //Finds beginning of a line, followed by e or E, and replaces it with A. At
 least it should do it, but it doesn't ?
 $tes = preg_replace(/^[eE]/, A,  $test);

This should work. However if you're using $test as defined above it does not 
start with 'e' or 'E' so what output did you expect??


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Bershere's Formula for Failure:
There are only two kinds of people who fail: those who
listen to nobody... and those who listen to everybody.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Regular Expressions (PCRE library)

2002-08-03 Thread Jürgen


Well, i know it should work, but it does not work.
Even if i Change the first letter into e or E it does not work.

This is so frustrating, this is prolly the most easiest regular expression i
could start with and yet i fail and nobody seems to know why it aint working
neither

 This should work. However if you're using $test as defined above it does
not
 start with 'e' or 'E' so what output did you expect??


 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Regular Expressions (PCRE library)

2002-08-03 Thread Jason Wong

On Sunday 04 August 2002 03:47, Jürgen wrote:
 Well, i know it should work, but it does not work.
 Even if i Change the first letter into e or E it does not work.

 This is so frustrating, this is prolly the most easiest regular expression
 i could start with and yet i fail and nobody seems to know why it aint
 working neither

  This should work. However if you're using $test as defined above it does

 not

  start with 'e' or 'E' so what output did you expect??

So you're saying this:

  echo preg_replace(/^[eE]/, A,  Eek!);

Does not result in Aek! ?

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
The problem with graduate students, in general, is that they have
to sleep every few days.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Regular Expressions (PCRE library)

2002-08-03 Thread Jürgen

No im not saying that, im merely saying that in my given example even if i
turn the Hello into Ello it does not replace it, besides :


^  = assert start of subject (or line, in multiline mode)   *


I took this directly from the PHP manual, so i assumed that the default mode
would be the first one, however, i tried the following and it looks like it
was the latter after all

$test = ello, end this is now the End.;

$test = preg_replace('# *^e#i', 'A',  $test);

Will result into :  Allo, end this is now the End.

So, i guess you were right after all :)

Thanks for sticking with me though!

Best regards from Vienna,
Jürgen


 So you're saying this:

   echo preg_replace(/^[eE]/, A,  Eek!);

 Does not result in Aek! ?

 --
 Jason Wong



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php