Answers for "php preg_replace callback"

PHP
2

preg_replace

<?php
$string = 'April 15, 2003';
$pattern = '/(\w+) (\d+), (\d+)/i';
$replacement = '${1}1,$3';
echo preg_replace($pattern, $replacement, $string);
Posted by: Guest on August-02-2020
0

preg_replace examples

$result = preg_replace('/abc(def)hij/', '/\\1/', $string);
$result = preg_replace('/abc(def)hij/', '/$1/', $string);
$result = preg_replace('/abc(def)hij/', '/${1}/', $string);
Posted by: Guest on March-09-2021
0

preg_replace examples

$result = preg_replace(
    array('/pattern1/', '/pattern2/'),
    array('replace1', 'replace2'),
    $string
);
Posted by: Guest on March-09-2021
0

php preg_replace callback

$text = preg_replace_callback(

"/\\[\\[([^|]+\\|)(.*?)\\]\\]/",

[ $this, 'linkReplace' ],

$text

);

$text = preg_replace( "/<\/?[^>]+>/", "", $text );
return $text;
Posted by: Guest on July-31-2021
0

preg_replace examples

# Strip HTML tag
$result = preg_replace('#<span id="15">.*</span>#m', '', $string);
Posted by: Guest on March-09-2021

Browse Popular Code Answers by Language