New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
string t = Regex.Replace(s, @"[^\u0000-\u007F]+", string.Empty);
import std.array;
import std.algorithm.iteration;
import std.ascii;
auto t = s.filter!(a => a.isASCII).array;
import "regexp"
re := regexp.MustCompile("[[:^ascii:]]")
t := re.ReplaceAllLiteralString(s, "")
import Data.Char
f = filter isAscii
t = f s
import Data.Char
t = filter isAscii s
$t = preg_replace('/[^[:ascii:]]/', '', $s);
var
  i: integer;
begin
  t := '';
  for i := 1 to length(s) do
    if s[i] < #128 then t := t + s[i];
end.
uses RegExpr;
var
  s,t: string;
begin
  t := ReplaceRegExpr('[^\u0000-\u007F]+', s, '', False);
end.
import re
t = re.sub('[^\u0000-\u007f]', '',  s)
t = s.gsub(/[^[:ascii:]]/, "")
t = s.gsub(/[[:^ascii:]]/, "")
let t = s.replace(|c: char| !c.is_ascii(), "");