Purely out of interest and for offering other approaches, my first instinct was: Bin = <<"<B>Page Counter</B></TD><TD>4880</TD></TR>">>, {match, [{Index,Length}]} = re:run(Bin, <<"[0-9]+">>), <<_:Index/binary, Num:Length/binary, _/binary>> = Bin, list_to_integer(binary_to_list(Num)). /s