0

私はこのパターンを使用しています:

$line = preg_replace('#(\w)(\w)#e', "chr(hexdec('$1$2'))", $line);

しかし、これはこの文字列に役立ちます:"c8d3e320c7e1e1f8e520c7e1d1cde3e420c7e1d1cdede3fe"

たとえば、文字列を変換したい:-"\'c8\'d3\'e3\'20\'c7\'e1\'e1\'f8\'e5\'20\'c7\'e1\'d1\'cd\'e3\'e4\'20\'c7\'e1\'d1\'cd\'ed\'e3\'fe"

\' これは、パターンを変更する方法から始めたキャラクターを意味しますか?

ありがとう +Akam

このパターンで問題解決

  $line = preg_replace("#\\\'(\w)(\w)#e", "chr(hexdec('$1$2'))", $line);
4

1 に答える 1

0
$line = "\'c8\'d3\'e3\'20\'c7\'e1\'e1\'f8\'e5\'20\'c7\'e1\'d1\'cd\'e3\'e4\'20\'c7\'e1\'d1\'cd\'ed\'e3\'fe";
echo preg_replace("#\\'(\w)(\w)#e", "chr(hexdec('$1$2'))", $line);

//test
preg_match_all("#\\'(\w)(\w)#e", $line, $out);
echo '<pre>';
print_r($out);

    [1] => Array
        (
            [0] => c
            [1] => d
            [2] => e
            [3] => 2
            [4] => c
            [5] => e
            [6] => e
            [7] => f
            [8] => e
            [9] => 2
            [10] => c
            [11] => e
            [12] => d
            [13] => c
            [14] => e
            [15] => e
            [16] => 2
            [17] => c
            [18] => e
            [19] => d
            [20] => c
            [21] => e
            [22] => e
            [23] => f
        )

    [2] => Array
        (
            [0] => 8
            [1] => 3
            [2] => 3
            [3] => 0
            [4] => 7
            [5] => 1
            [6] => 1
            [7] => 8
            [8] => 5
            [9] => 0
            [10] => 7
            [11] => 1
            [12] => 1
            [13] => d
            [14] => 3
            [15] => 4
            [16] => 0
            [17] => 7
            [18] => 1
            [19] => 1
            [20] => d
            [21] => d
            [22] => 3
            [23] => e
        )

)
于 2013-02-22T21:12:38.253 に答える