I am creating a webserver that people connect to using telnet
.
Some telnet-clients send data per-line, but others send each and every character as soon as it is typed. In the server, I cache these until a newline is typed. (And therefore we have a full line)
However, backspace characters, (\x08
), are also sent and in the string. I would like to implement the backspace behaviour by replacing a character followed by a backspace with nothing.
However, what if a user uses backspace to remove more than one letter at a time?
is it possible to construct a regexp that removes an N amount of characters when followed by an N amount of backspaces?
For completeness sake, I'm using Ruby 2.2 .
Thanks.