[PHP] Regular Expressions

2004-08-05 Thread Arik Raffael Funke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi together,

I have a question about regular expressions. I want to get from
following text...

test: abc
def
ghi

...following...
abc
def
ghi

Can anybody tell me why preg_match(/test([.\n]*)/,...) does not work?
And who is it done properly?

Thanks very much in advance.

Cheers,
Arik
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBEpSR//PXyz2NiW8RAscoAKCSukZ7/Cur9caw2/Vmss2Ktwb7YQCgpV3b
qkI7b1gPSrK0bJjLeTmokMk=
=5pzG
-END PGP SIGNATURE-

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



[PHP] Regular Expressions

2004-07-15 Thread Arik Raffael Funke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello together,

I am havin trouble with php regular expressions. I would like to
implement following pattern Last Name:\s*(.*)\n.

- From following text,
Name: James
Last Name: Jason
Street: abc

I get just 'Jason'. But what I currently get is:
Jason
Street: abc

Obviously the new-line is missed. Any thoughts on this?

sample code:
ereg(Last Name:\s*(.*)\n, $strInput, $regs)
echo $regs[1];

Thanks for the help!

Cheers,
Arik
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFA9ns4//PXyz2NiW8RAuLDAJ0eBoCsJvT919/9xoVdk+BUkc8pegCeJ6O0
PxeXTxOwxr4WF639fZpDFYs=
=3BQA
-END PGP SIGNATURE-

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



Re: [PHP] Regular Expressions

2004-07-15 Thread Arik Raffael Funke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thu, 15 Jul 2004 08:02:13 -0500
Matt M. [EMAIL PROTECTED] wrote:

  Obviously the new-line is missed. Any thoughts on this?
  
  sample code:
  ereg(Last Name:\s*(.*)\n, $strInput, $regs)
  echo $regs[1];
 
 try this:
 
 ereg(Last Name:\s*(.*[^\n]), $strInput, $regs);
 echo $regs[1];
 

Thanks for the quick help.

Both ways,
preg_match('/Last Name:\s*(.*)\n/', $inputStr, $regs);
and
ereg(Last Name:\s*(.*[^\n]), $strInput, $regs);
work fine.

However if I have,
Last Name:
Street: Teststreet
(no entry after last name)

Both search strings return me:
- 

Street: Teststreet
- 

Also why doesn't Last Name:\s*(.*)$ work, and neither ^Last
Name:\s*(.*). Both strings are not found at all - that's why I thought
the php implementation might treat new lines in a strange way.

Can anybody explain these effects to me?

Cheers,
Arik
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFA9oN1//PXyz2NiW8RAmCQAJ9wRDxc8YDyfU+4EoNeRsqMKJDPBQCgsMvv
7cpFD6cYZuckqGdY+1Gtqi8=
=Hi/P
-END PGP SIGNATURE-

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