Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have a string like:$str='&%#^*@\"~ \'a4{=s{sa*}7s*&$db{abc654d3ws67}d(*$%#$c6'#^*@"~ \'a4\"'; .
$str='&%#^*@\"~ \'a4{=s{sa*}7s*&$db{abc654d3ws67}d(*$%#$c6'#^*@"~ \'a4\"';
I need to find what is not like {abc654d3ws67} as $needle from that string and preplace it by bin2hex($needle).
{abc654d3ws67}
$needle
bin2hex($needle)
Example: bin2hex('#').
bin2hex('#')
のすべての出現箇所を検索し{、その後に任意の数の文字または数字が続き、その後に}.
{
}
$str = preg_replace_callback( '/\{([^a-z0-9]+)\}/i', function( $match) { return bin2hex( $match[1]); }, $str);