[Question]
  [
On some terminals, pressing backspace generates the control code `^H` to delete the previous character. This gave rise to a snarky idiom where [edits are feigned for comedic effect](http://www.catb.org/~esr/jargon/html/writing-style.html):
> 
> Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate
>  HQ.
> 
> 
> 
Given a string with one or more `^H`'s, output the result of backspacing on each `^H`. The input will use only printable characters (ASCII 32-126), and `^` will only appear as `^H`. Backspaces will never happen on empty text.
You may not assume that the output environment supports control codes, in particular the backspace code `\x08`.
```
>> Horse^H^H^H^H^HCow
Cow
>> Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ.
Be nice to this gentleman, he's visiting from corporate HQ.
>> 123^H45^H^H^H78^H
17
>> Digital Trauma^H^H^H^H^H^H^H^H^H^H^H^H^H^HMaria Tidal Tug^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HDigital Trauma
Digital Trauma
```
## Leaderboard
Here's a by-language leaderboard, courtesy of [Martin Büttner](https://codegolf.stackexchange.com/users/8478/martin-b%C3%BCttner).
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
```
# Language Name, N bytes
```
where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:
```
# Ruby, <s>104</s> <s>101</s> 96 bytes
```
```
function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/52946/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);i=i.replace("{{PLACE}}",t++ +".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=45497;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:&lt;(?:s&gt;[^&]*&lt;\/s&gt;|[^&]+&gt;)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*((?:[^,\s]|\s+[^-,\s])*)/
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script><link rel=stylesheet type=text/css href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><div id=answer-list><h2>Leaderboard</h2><table class=answer-list><thead><tr><td></td><td>Author<td>Language<td>Size<tbody id=answers></table></div><div id=language-list><h2>Winners by Language</h2><table class=language-list><thead><tr><td>Language<td>User<td>Score<tbody id=languages></table></div><table style=display:none><tbody id=answer-template><tr><td>{{PLACE}}</td><td>{{NAME}}<td>{{LANGUAGE}}<td>{{SIZE}}<td><a href={{LINK}}>Link</a></table><table style=display:none><tbody id=language-template><tr><td>{{LANGUAGE}}<td>{{NAME}}<td>{{SIZE}}<td><a href={{LINK}}>Link</a></table>
```
  
[Answer]
# GNU sed, 11 bytes
```
:;s/.^H//;t
```
### Test output:
```
$ echo "Horse^H^H^H^H^HCow
Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ.
123^H45^H^H^H78^H
Digital Trauma^H^H^H^H^H^H^H^H^H^H^H^H^H^HMaria Tidal Tug^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HDigital Trauma" | sed ':;s/.^H//;t'
Cow
Be nice to this gentleman, he's visiting from corporate HQ.
17
Digital Trauma
$ 
```
[Answer]
# Pyth, 11 bytes
```
.U+PbZcz"^H
```
[Demonstration.](https://pyth.herokuapp.com/?code=.U%2BPbZcz%22%5EH&input=123%5EH45%5EH%5EH%5EH78%5EH&debug=0)
```
.U+PbZcz"^H
               Implicit: z = input()
      cz"^H    z.split("^H")
.U             reduce, with the first element of the list as the initial value.
   Pb          Remove the last character of what we have so far.
  +  Z         And add on the next segment.
               Print implicitly.
```
[Answer]
# Gema, 6 bytes
```
?#\^H=
```
Sample run:
```
bash-4.3$ gema -p '?#\^H=' <<< 'pizza is alright^H^H^H^H^H^Hwesome'
pizza is awesome
```
CW, because the fool vs. gentleman example takes far too long. (Killed after a day. Maybe a glitch in the interpreter? All other examples here are processed in fractions of seconds.) Gema's recursive pattern not seems to be affected by the recursion level, but the amount of non-matching text increases processing time exponentially.
[Answer]
# C, 52 bytes
```
j;f(char*s){for(j=0;*s=s[j];s[j]==94?s--,j+=3:s++);}
```
We define a function `f` that takes a pointer to the string as input. After the function call, that pointer will contain a modified string.
A simple test:
```
int main(int argc, char** argv) {
    char buf[300] = "Digital Trauma^H^H^H^H^H^H^H^H^H^H^H^H^H^HMaria Tidal Tug^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HDigital Trauma";
    f(buf);
    printf(buf);
    return 0;
}
```
The above prints:
```
Digital Trauma
```
[Answer]
# Haskell, 47 bytes
```
h(a,_:_:b)=f$init a++b;h(x,_)=x
f=h.span(/='^')
```
Defines a function `f :: String -> String`. How it works:
```
    f "ab^Hc^Hd"
=== h ("ab", "^Hc^Hd")   (find ^H)
=== f ("a" ++ "c^Hd")    (backspace)
=== f "ac^Hd"            (join)
=== h ("ac", "^Hd")      (find ^H)
=== f ("a", "d")         (backspace)
=== f "ad"               (join)
=== h ("ad", "")         (find ^H)
=== "ad"                 (no ^H: base case)
```
[Answer]
# CJam, ~~14~~ 13 bytes
```
q"^H"/{W\ts}*
```
**How it works**
```
q                   e# Read the entire input
 "^H"/              e# Split it on occurrences of string "^H"
      {    }*       e# Reduce on the split array
       W\t          e# This is the tricky part. We know that if there are two parts that we
                    e# are reducing on, they must be separated by "^H". Which in turn means
                    e# that from the first part, last characters needs to be deleted
                    e# So we simply put the second part in place of the last character of the
                    e# first part.
          s         e# Doing the above makes it a mixed array of character and string.
                    e# So we convert it to a single string, ready to be served as first part
                    e# in next reduce iteration
```
*UPDATE: 1 byte saved thanks to jimmy23013*
[Try it online here](http://cjam.aditsu.net/#code=q%22%5EH%22%2F%7BW%5Cts%7D*&input=Digital%20Trauma%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EHMaria%20Tidal%20Tug%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EHDigital%20Trauma)
[Answer]
# Retina, 13 bytes
[Retina](https://github.com/mbuettner/retina)
```
+`.\^H(.*)
$1
```
The two lines should go to their own files but you can run the code as one file with the `-s` flag.
At each step we delete the first match for `.\^H` in the string. We repeat this (with the `+` modifier) until no deletion happens.
[Answer]
# JavaScript (*ES6*), 39 bytes
```
f=s=>(t=s.replace(/.\^H/,''))!=s?f(t):t
// TEST
Out=x=>O.innerHTML+=x+'\n'
Test=_=>(Out(I.value + "\n-> " + f(I.value)),I.value='')
;["Horse^H^H^H^H^HCow"
,"Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
,"123^H45^H^H^H78^H"
,"Digital Trauma^H^H^H^H^H^H^H^H^H^H^H^H^H^HMaria Tidal Tug^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HDigital Trauma"]
.forEach(t => Out(t + "\n-> " + f(t)))
```
```
#I { width:400px }
```
```
<pre id=O></pre>
<input id=I><button onclick='Test()'>-></button>
```
[Answer]
# Perl, ~~20~~ ~~16~~ 15 bytes
(14 characters code + 1 character command line option.)
```
s/.\^H//&&redo
```
Sample run:
```
bash-4.3$ perl -pe 's/.\^H//&&redo' <<< "Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
Be nice to this gentleman, he's visiting from corporate HQ.
```
[Answer]
# Julia, ~~58~~ ~~42~~ 41 bytes
Saved 16 bytes thanks to manatwork and 1 thanks to Glen O!
```
f(s)='^'∈s?f(replace(s,r".\^H","",1)):s
```
This creates a recursive function that accepts a string and returns a string.
This replaces one occurrence of `^H` at a time with an empty string while the input contains `^`.
Examples:
```
julia> f("123^H45^H^H^H78^H")
"17"
julia> f("pizza is alright^H^H^H^H^H^Hwesome")
"pizza is awesome"
```
[Answer]
# REGXY, 10 bytes
Uses [REGXY](http://esolangs.org/wiki/REGXY), a regex substitution based language. Replaces any character followed by ^H with nothing. The second line then executes which is just a pointer to the previous line, repeating the substitution until it fails to match.
```
/.\^H//
//
```
This compiles and executes correctly with the sample interpreter in the link above, but the solution is perhaps a bit cheeky as it relies on an assumption in the vagueness of the language specification. The spec states that the first token on each line (before the /) acts as a label, but the assumption is that a null label-pointer will point back to the first command in the file with a null label (or in other words, that 'null' is a valid label). A less cheeky solution would be:
```
a/.\^H//
b//a
```
Which amounts to 13 bytes.
[Answer]
# Python 3, 53 bytes
```
o=""
for x in input().split("^H"):o=o[:-1]+x
print(o)
```
But personally I like this wordier version better:
```
H=input().split("^H")
print(eval("("*~-len(H)+")[:-1]+".join(map(repr,H))))
```
The interesting thing is that
```
'B''a''c''k''h''a''n''d''e''d'[:-1][:-1][:-1][:-1][:-1][:-1]
```
actually works and gives `'Back'`, so I tried to map `^H -> [:-1]` and any other char `c -> 'c'` then `eval`, but unfortunately you can't have any strings afterwards without a `+`, so this fails:
```
'B''a''c''k''h''a''n''d''e''d'[:-1][:-1][:-1][:-1][:-1][:-1]'s''p''a''c''e''s'
```
[Answer]
# Haskell, ~~52~~ 47 bytes
```
import Data.Lists
foldl1((++).init).splitOn"^H"
```
Usage example:
```
> map (foldl1((++).init).splitOn"^H") ["Horse^H^H^H^H^HCow", "123^H45^H^H^H78^H", "Digital Trauma^H^H^H^H^H^H^H^H^H^H^H^H^H^HMaria Tidal Tug^H^H^H^H^H^H^H^H^H^H^H^H^H^H^HDigital Trauma"]
["Cow","17","Digital Trauma"]
```
How it works:
```
                  splitOn"^H"     -- split on substring "^H", e.g "Horse^H^H^H^H^HCow" -> ["Horse","","","","","Cow"]
                 .                -- then
foldl1(         )                 -- fold from left by
            init                  --   first dropping the last char from the left argument
       (++).                      --   second concatenating left and right argument
```
[Answer]
# Ruby, ~~27~~ ~~24~~ 20 bytes
(19 characters code + 1 character command line option.)
```
$_=$`+$'while/.\^H/
```
Thanks to:
* [Ventero](https://codegolf.stackexchange.com/users/84/ventero) for suggesting to use the global variables (-4 characters)
Sample run:
```
bash-4.3$ ruby -pe '$_=$`+$'"'"'while/.\^H/' <<< "Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."
Be nice to this gentleman, he's visiting from corporate HQ.
```
[Answer]
# [Vim](https://www.vim.org/), 12 bytes
```
qqt^3xh@qq@q
```
[Try it online!](https://tio.run/##JcIxCoAwDAXQq/zNRVy8QHHq6gUKItEG2sa0oXj7Osh7fQxVC@sbnarTMTZC4ZNgAovccImk4H83FUuUjzIj0tTQubFxuXFVyTilPlIPI/h9@QA "V (vim) – Try It Online")
Makes use of the fact that "`^` will only appear as `^H`".
### Explanation
```
qqt^3xh@qq@q
qq     @qq@q    Define an indefinitely looping recursive macro and immediately call it
  t^            Move to just before the next ^ character in the line
    3x          Delete 3 characters (the one to be deleted, ^, and H)
      h         Move left 1 step (to be in position for the next search)
```
[Answer]
# [V (vim)](https://github.com/DJMcMayhem/V), ~~16~~ 14 bytes
```
qq:s/.^H
@qq@q
```
[Try it online!](https://tio.run/##JcIxCoAwDAXQ3VP8zUV0dypOXb2AUCRqQBvThl4/DvJec1ed6zRusQuqQd0XQuadYAK7uOIQubf4OynbTU/KAy7qKxpXNs4njiIPdimvlGSEuI4f "V (vim) – Try It Online")
similar to sed, but uses Vim's recursion.
[Answer]
# Pyth - 19 bytes
Reduce works really, really well with this but it only does one char at a time so I had to spend almost as many chars as the actual algo to do a replace `^H` with linebreak. Looking for a better way to do that.
```
u?+GHnHbPGjbcz"^H"k
```
[Try it online here](http://pyth.herokuapp.com/?code=u%3F%2BGHnHbPGjbcz%22%5EH%22k&input=Be%20nice%20to%20this%20fool%5EH%5EH%5EH%5EHgentleman%2C%20he%27s%20visiting%20from%20corporate%20HQ.&debug=1).
[Answer]
# Python 2, 50
It's a bit odd having a second `lambda` in there, but seems to be the best Python so far.
```
lambda s:reduce(lambda a,b:a[:-1]+b,s.split('^H'))
```
[Answer]
# Julia, ~~41~~ 39 bytes
```
s->foldl((t,v)->chop(t)v,split(s,"^H"))
```
What it's doing is using ^H as a delimiter, and then removing the last character on each string then concatenating the next string before removing the last character again. Unlike the other Julia answer, this is not a recursive function.
Note: I've removed the function name from the definition. Originally, it said `f(s)=` rather than `s->`, and you used it as `f("AAA^HB^H^H")`... but I'm saving two bytes by letting it be "anonymous", and use itself as its name. You use it like this:
```
(s->foldl((t,v)->chop(t)v,split(s,"^H")))("AAA^HB^H^H")
```
(you can also assign a variable to it as `f=s->foldl((t,v)->chop(t)v,split(s,"^H"))`, then `f("AAA^HB^H^H")` will work)
[Answer]
# [TeaScript](http://github.com/vihanb/TeaScript), 7 bytes [Not competing]
**Not competing** as TeaScript was made after this challenge was posted. This is here as reference.
```
xW/.\^H
```
This uses the new TeaScript 3, and recursive replaces to remove the characters
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 81 bytes
```
>,[[>+>+<<-]-[>-<---]>---------[>>+<<[-]]>>-[+<[-]<<<,[-]>>]<[<<+>>-]<,]<[<]>[.>]
```
[Try it online!](https://tio.run/##fUyrDsMwEPuV8uT2BZbRQElZ2ekqXTe1Ou0BouX7swYMDGw2sGVbXovHc6uXW2vMqkxMgJgoBSJilA@UvVIxI0VTdwDyIaRBgXTkhty9UU@01s6xx8vvw1y8PnwZf3PyEj7Mce3ruv@bLuP37Rs "brainfuck – Try It Online")
[Answer]
# K5, 64 bytes
K isn't really designed for this kind of work...
```
{[s]$[2>#s;s;`=t:*&{"^H"~2#x_s}'1+!-2+#s;s;,/2#2!|(0,t,3+t)_s]}/
```
[Answer]
# golflua, 36 bytes
```
\f(s)@o!=s o=s;s=s:g(".^H","",1)$~s$
```
Sample run:
```
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> \f(s)@o!=s o=s;s=s:g(".^H","",1)$~s$
> w(f("Be nice to this fool^H^H^H^Hgentleman, he's visiting from corporate HQ."))
Be nice to this gentleman, he's visiting from corporate HQ.
```
[Answer]
# Javascript, 62 bytes
Not the shortest one, but works fine.
```
t=prompt();while(t.match(R=/.\^H/))t=t.replace(R,'');alert(t);
```
This probably can be shortened a lot!
[Answer]
# R, ~~54~~ 52 bytes
```
f=function(s)ifelse(s==(r=sub(".\\^H","",s)),r,f(r))
```
Same basic idea as [my Julia answer](https://codegolf.stackexchange.com/a/52959/20469). This creates a recursive function that accepts a string and returns a string. If the input is equal to itself with a single occurrence of `^H` removed, return it, otherwise call the function again.
You can [try it online](http://www.r-fiddle.org/#/fiddle?id=FJNnw6Xp)!
[Answer]
# ECMAScript 6, 57 bytes
```
s=>{while(~s.indexOf`^H`)s=s.replace(/.\^H/,'');return s}
```
This is ~~probably golfable, just gotta think of a way~~ probably not
[Answer]
# Java, ~~78~~ 77 bytes
```
String f(String a){while(!a.equals(a=a.replaceFirst(".\\^H","")));return a;}
```
[Answer]
# (Visual)FoxPro any version 80 bytes
```
PARA t
DO WHILE AT('^H',t)>0
t = STRT(t,SUBS(t,AT('^H',t)-1,3))
ENDDO
RETU t
```
Repeating string translation to empty by finding ^H and backing up one character.
[Answer]
# rs, 8 bytes
Technically, this doesn't count, as it depends on a feature I added after this question was posted. However, I think it's pretty neat.
```
+?1.\^H/
```
[Live demo and test cases](http://kirbyfan64.github.io/rs/index.html?script=%2B%3F1.%5C%5EH%2F&input=Horse%5EH%5EH%5EH%5EH%5EHCow%0ABe%20nice%20to%20this%20fool%5EH%5EH%5EH%5EHgentleman%2C%20he%27s%20visiting%20from%20corporate%20HQ.%0A123%5EH45%5EH%5EH%5EH78%5EH%0ADigital%20Trauma%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EHMaria%20Tidal%20Tug%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EH%5EHDigital%20Trauma).
[Answer]
# Vim, ~~38~~ 35 bytes
Saved 3 bytes thanks to Leo!
```
qa:%s/\([^H]\|\^\@<!.\)\^H//g
@aq@a
```
[Try it online!](https://tio.run/##K/v/vzDRSrVYP0YjOs4jNqYmJi7GwUZRL0YzJs5DXz@dyyGx0CHx/3@P/KLi1DgPGHTOLwcA "V (vim) – Try It Online")
See [Razetime's answer](https://codegolf.stackexchange.com/a/223119/95792) for a shorter and smarter version of this.
```
qa:%s/\([^H]\|\^\@<!.\)\^H//g
@aq@a
qa                                     Start recording a macro a
  :%s/                                 Substitute in entire file
      \([^H]\|\^\@<!H\)                Regex for the character to be deleted
        [^H]                           A character that isn't H
            \|                         or
                    H                  an H
              \^\@<!                   that doesn't have a ^ before it
                       \^H             All of that followed by ^H
                          //           Replace with empty string
                            g          Global flag so it replaces multiple times
                                       Enter the command
@a                                     Recursively call macro a
  q                                    Stop recording
   @a                                  Run the macro
```
```
]