diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/pcre/tests/pcre_count.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/pcre/tests/pcre_count.phpt')
-rw-r--r-- | ext/pcre/tests/pcre_count.phpt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/pcre/tests/pcre_count.phpt b/ext/pcre/tests/pcre_count.phpt new file mode 100644 index 0000000..1239d48 --- /dev/null +++ b/ext/pcre/tests/pcre_count.phpt @@ -0,0 +1,40 @@ +--TEST-- +preg_replace() fifth parameter - count +--FILE-- +<?php +$regex = '/(([0-9a-z]+)-([0-9]+))-(([0-9]+)-([0-9]+))/'; + +$string= '1-2-3-4 a-2-3-4 1-a-3-4 1-2-a-4 1-2-3-a a-a-a-a 4-3-2-1 100-200-300-400-500-600-700-800'; +$count = 0; +var_dump(preg_replace($regex, 'xxxx', $string, -1, $count)); +var_dump($count); +////////////////////////////////////////////////////// + +$regex = '/([a-z]+)/'; + +$string= 'Here must only number like 42 and 13 appear'; +var_dump(preg_replace($regex, 'xxxx', $string, -1, $count)); +var_dump($count); + +//////////////////////////////////////////////////////// +$regex = '~((V(I|1)(4|A)GR(4|A))|(V(I|1)C(0|O)D(I|1)(N|\/\\\/)))~i'; + +$string= 'Viagra V14GR4 Vicodin V1C0D1/\/ v1c0d1/|/'; +var_dump(preg_replace($regex, '...', $string, -1, $count)); +var_dump($count); +//////////////////////////////////////////////////////// +$regex = '~((V(I|1)(4|A)GR(4|A))|(V(I|1)C(0|O)D(I|1)(N|\/\\\/)))~i'; +$count = NULL; +$string= 'Viagra V14GR4 Vicodin V1C0D1/\/ v1c0d1/|/'; +var_dump(preg_replace($regex, '...', $string, -1)); +var_dump($count); +?> +--EXPECT-- +string(56) "xxxx xxxx 1-a-3-4 1-2-a-4 1-2-3-a a-a-a-a xxxx xxxx-xxxx" +int(5) +string(41) "Hxxxx xxxx xxxx xxxx xxxx 42 xxxx 13 xxxx" +int(7) +string(25) "... ... ... ... v1c0d1/|/" +int(4) +string(25) "... ... ... ... v1c0d1/|/" +NULL |