Baran Topal

Baran Topal


April 2024
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
2930  

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]);

?>