Re: [PHP4BETA] Regex Question/preg_replace

From: Date: Wed, 19 Apr 2000 15:44:08 +0000
Subject: Re: [PHP4BETA] Regex Question/preg_replace
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-13747@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 19.04.00 um 09:45 hat Andrei Zmievski geschrieben: AZ>On Wed, 19 Apr 2000, Jonas Jochum wrote: AZ>> I'm wondering if there's something like Perl's $+ in PHP4. I couldn't AZ>> find AZ>> anything in the docs, except that preg_replace accepts arrays. But that AZ>> doesn't help in my special case... AZ>What do you need the $+ functionality for that you can't achieve with AZ>direct enumeration? Actually, after thinking about it a bit more, you're right... This probably could be done with direct enumeration. However, it would still be neat to be able to do something like that: $content =~ s/\$(?:([A-Z][A-Z0-9_]+)|\{([A-Z][A-Z0-9_]+)\})/ my $rep_val = $assign{$+}; if (!defined($rep_val)) { $rep_val = ""; } else { $rep_val = $assign{$+}; } $rep_val; /ge; Gotta think about how that could be done in PHP a bit more. AZ>> now another problem...when I used preg_match_all(), PHP returned an array AZ>> with infinite dimensions, it seems. I couldn't get to the data. PHP kept AZ>> printing Array(x)...I'll test that later today again, as soon as I have AZ>> time to install the latest CVS version. AZ>Please let me know what you find. arghh...I just found the problem. It was a subtle bug in my script. Sorry for the confusion! :( - -- Reg., Jonas Jochum commandline net services - ------------------------------------------------------------------------- tel: 07223-911794 | cmd:~ # Systemadministration, Netzwerkverwaltung fax: 07223-911795 | cmd:~ # Einrichtung von *BSD/Linux-Servern jj@commandline.de | cmd:~ # Datenbank/Internetprogrammierung www.commandline.de | cmd:~ # Webdesign -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (FreeBSD) Comment: Made with pgp4pine iEYEARECAAYFAjj91EsACgkQF1ki3orczCC1cQCfYeT8O5HNrrNCFiZ+i4LI9JQd o4UAnRK8xPKHr0PBuo2ZtrBJwIf6eNhv =z2Cs -----END PGP SIGNATURE-----

« previous php.version4 (#13747) next »