PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Valgrind Report for ext/pcre/tests/preg_replace_edit_basic.phpt ('Test preg_replace() function : basic')

Script

1: <?php
2:
/* Prototype  : proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
3:  * Description: Perform Perl-style regular expression replacement. 
4:  * Source code: ext/pcre/php_pcre.c
5:  * Alias to functions: 
6: */
7:
8:
$string '123456789 - Hello, world -           This is a string.';
9:
var_dump($string);
10:
11:
var_dump(preg_replace('<- This is a string$>',
12:                       
'This shouldn\'t work'$string));                //tries to find '- This is a string' at the end of a string but can't so replaces nothing and prints the unchanged $string.
13:
14:
var_dump(preg_replace('<[0-35-9]>'
15:                       
'4'$string,                                   //finds any number that's not 4 and replaces it with a 4
16:                 
'5'$count));                            //limits to 5 replacements returns 444444789
17:
var_dump($count);                                            //counts the number of replacements made (5)
18:
19:
20:
var_dump(preg_replace('<\b[hH]\w{2,4}>',
21:                       
'Bonjour'$string));                        //finds h or H at the beginning of a word followed by 2-4 characters and replaces it with Bonjour (i.e. Hello -> Bonjour) (was finding the 'his' in This and replacing it)
22:
23:
var_dump(preg_replace('<(\w)\s*-\s*(\w)>',
24:                       
'\\1. \\2'$string));                        //finds dashes with an indefinite amount of whitespace around them and replaces them with a full stop precedeby no spaces and followed by one space
25:
26:
var_dump(preg_replace('<(^[a-z]\w+)@(\w+)\.(\w+)\.([a-z]{2,}$)>'
27:                       
'\\1 at \\2 dot \\3 dot \\4''josmessa@uk.ibm.com'));    //finds the e-mail address and replaces the @ and . with "at" and "dot" (uses backreferences) ('josmessa at uk dot ibm dot com')
28:
?>
29:

Report

==12239== Conditional jump or move depends on uninitialised value(s)
==12239==    at 0x4140A67: ???
==12239==    by 0x14F2DE18: ???
==12239==    by 0x14F2DE07: ???
==12239==    by 0x14F2DE3D: ???
==12239==    by 0x1FFEFFBC8F: ???
==12239==    by 0x14F37BAF: ???
==12239== 

 

Generated at Sun, 24 Sep 2017 15:32:56 +0000 (39 hours ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.