"\1\2abc\xAA".scan(/\1\2(.*?)\xAA/)[1]

[11] pry(main)> s= "\1\2abc\xAA"
=> "\u0001\u0002abc\xAA"
[12] pry(main)> s.scan(/\001\002(.*?)\xAA/)
SyntaxError: (eval):2: invalid multibyte escape: /\001\002(.*?)\xAA/

how to scan that abc string ?

it is a hex string in a device's serial communication .

-- 
Posted via http://www.ruby-forum.com/.