In Ruby it is dead simple:
str[/\[(.*)\]/,1].hex # "=> 37"
I always wondering when people think it is dead simple.
I use streams for such cases. It is logical, readable and dead simple approach without crappy syntax. And with Xtreams library it become much more easy and fun