Make WordPress Core

Ticket #2774: 2774c-preg.diff

File 2774c-preg.diff, 4.0 KB (added by mdawaffe, 18 years ago)

preg_backslashit

  • wp-includes/functions-formatting.php

     
    521521
    522522function zeroise($number,$threshold) { // function to add leading zeros when necessary
    523523        return sprintf('%0'.$threshold.'s', $number);
    524         }
     524}
    525525
    526526
     527function preg_backslashit($string) {
     528        $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
     529        $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
     530        return $string;
     531}
     532
    527533function backslashit($string) {
    528534        $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
    529535        return $string;
  • wp-includes/functions.php

     
    3737                $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
    3838                $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
    3939                $dateformatstring = ' '.$dateformatstring;
    40                 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
    41                 $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
    42                 $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
    43                 $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
    44                 $dateformatstring = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring);
    45                 $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring);
     40                $dateformatstring = preg_replace("/([^\\\])D/", "\\1".preg_backslashit($dateweekday_abbrev), $dateformatstring);
     41                $dateformatstring = preg_replace("/([^\\\])F/", "\\1".preg_backslashit($datemonth), $dateformatstring);
     42                $dateformatstring = preg_replace("/([^\\\])l/", "\\1".preg_backslashit($dateweekday), $dateformatstring);
     43                $dateformatstring = preg_replace("/([^\\\])M/", "\\1".preg_backslashit($datemonth_abbrev), $dateformatstring);
     44                $dateformatstring = preg_replace("/([^\\\])a/", "\\1".preg_backslashit($datemeridiem), $dateformatstring);
     45                $dateformatstring = preg_replace("/([^\\\])A/", "\\1".preg_backslashit($datemeridiem_capital), $dateformatstring);
    4646
    4747                $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    4848        }
     
    8080                $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
    8181                $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
    8282                $dateformatstring = ' '.$dateformatstring;
    83                 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
    84                 $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
    85                 $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
    86                 $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
    87                 $dateformatstring = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring);
    88                 $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring);
     83                $dateformatstring = preg_replace("/([^\\\])D/", "\\1".preg_backslashit($dateweekday_abbrev), $dateformatstring);
     84                $dateformatstring = preg_replace("/([^\\\])F/", "\\1".preg_backslashit($datemonth), $dateformatstring);
     85                $dateformatstring = preg_replace("/([^\\\])l/", "\\1".preg_backslashit($dateweekday), $dateformatstring);
     86                $dateformatstring = preg_replace("/([^\\\])M/", "\\1".preg_backslashit($datemonth_abbrev), $dateformatstring);
     87                $dateformatstring = preg_replace("/([^\\\])a/", "\\1".preg_backslashit($datemeridiem), $dateformatstring);
     88                $dateformatstring = preg_replace("/([^\\\])A/", "\\1".preg_backslashit($datemeridiem_capital), $dateformatstring);
    8989
    9090                $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    9191        }