|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-09-13 21:23 UTC] thow at gmx dot net
[2000-09-13 23:45 UTC] andrei@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 10:00:02 2025 UTC |
SCRIPTS: ===== regexp.pl (works like expected): ====== #!/usr/bin/perl -w sub process_hashmark { my $s = shift @_; if ($s eq '') { print "Matched string: empty string\n"; } else { print "Matched string: $s\n"; } return 'XX' if ($s eq ''); return 'ZZZ'; } my $s; my $regexp = 'X([^X]*?)X'; if (defined $ARGV[0]) { $s = $ARGV[0]; } else { $s = 'abcXdefXghi'; } print "Regular Expression: $regexp\n"; print "String to process: $s\n"; $s =~ s/$regexp/process_hashmark($1)/ge; print "Processed String: $s\n"; ===== regexp.pl (end) regexp.php (works not like expected): ===== function process_hashmark($string) { if ($string == "") { print "Matched string: empty string<br>\n"; } else { print "Matched string: $string<br>\n"; } if ($string == "") return "XX"; return "ZZZ"; } $regexp = "X([^X]*?)X"; if (empty($s)) $s = "abcXdefXghi"; echo "Regular Expression: $regexp<br>\n"; echo "String to process: $s<br>\n"; $s = preg_replace("/$regexp/e", "process_hashmark(\\1);", $s); echo "Processed string: $s<br>\n"; ===== regexp.php (end) OUTPUT: ===== regexp.pl (case 1): Regular Expression: X([^X]*?)X String to process: abcXdefXghi Matched string: def Processed String: abcZZZghi regexp.pl (case 2): Regular Expression: X([^X]*?)X String to process: abcXXdefXghi Matched string: empty string Processed String: abcXXdefXghi regexp.php (case 1): Regular Expression: X([^X]*?)X String to process: abcXdefXghi Matched string: def Processed string: abcZZZghi regexp.php (case 2): Regular Expression: X([^X]*?)X String to process: abcXXdefXghi Matched string: XdefXghi Processed string: abcZZZdefXghi CONFIGURE LINE: ===== ./configure --with-apxs --with-pgsql=/usr/lib/pgsql --with-mysql=/usr php.ini should be irrelevant and there is nothing special in our setup