Baran Topal

Baran Topal


May 2024
M T W T F S S
« Feb    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories


extract a hexadecimal string

baranbaran

I had been fiddling with php and needed to extract a string literal. Note that there are many many ways to solve this but I’d like to go with this:

<?php

$str = 'Found PID 0x1011, stream id 0xE0 = Video Stream 0';
preg_match('/id (0x[0-9a-f]+) = Video/i', $str, $m);
print_r($m[1]);

?>