Remove vowels from a string: Difference between revisions

m
(adding lambdatalk contribution)
 
(21 intermediate revisions by 14 users not shown)
Line 9:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">F exceptGlyphs(exclusions, s)
R s.filter(c -> c !C @exclusions).join(‘’)
 
Line 20:
in one approach to a problem in learning another.’
 
print(exceptGlyphs(‘eau’, txt))</langsyntaxhighlight>
 
{{out}}
Line 35:
=={{header|8080 Assembly}}==
 
<langsyntaxhighlight lang="8080asm"> org 100h
jmp demo
;;; Remove the vowels from the $-terminated string at [DE]
Line 65:
mvi c,9 ; Print using CP/M
jmp 5
string: db 'THE QUICK BROWN FOX jumps over the lazy dog$'</langsyntaxhighlight>
 
{{out}}
Line 72:
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">BYTE FUNC IsVovel(CHAR c)
CHAR ARRAY vovels="AEIOUaeiou"
BYTE i
Line 110:
Test("The Quick Brown Fox Jumped Over the Lazy Dog's Back")
Test("Action! is a programming language for Atari 8-bit computer.")
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Remove_vowels_from_a_string.png Screenshot from Atari 8-bit computer]
Line 126:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
 
Line 156:
Put_Line (NV2);
end Main;
</syntaxhighlight>
</lang>
{{output}}
<pre>
Line 167:
 
=={{header|ALGOL 68}}==
<langsyntaxhighlight lang="algol68">BEGIN
# returns s with the vowels removed #
OP DEVOWEL = ( STRING s )STRING:
Line 191:
test devowel( "abcdefghijklmnoprstuvwxyz" );
test devowel( "Algol 68 Programming Language" )
END</langsyntaxhighlight>
{{out}}
<pre>
Line 202:
 
=={{header|APL}}==
<syntaxhighlight lang APL="apl">devowel ← ~∘'AaEeIiOoUu'</langsyntaxhighlight>
{{out}}
<pre> devowel 'THE QUICK BROWN FOX jumps over the lazy dog'
Line 217:
We can also improve productivity by using library functions whenever feasible.
 
<langsyntaxhighlight lang="applescript">------- REMOVE A DEFINED SUBSET OF GLYPHS FROM A TEXT ------
 
-- exceptGlyphs :: String -> String -> Bool
Line 324:
set my text item delimiters to dlm
s
end unlines</langsyntaxhighlight>
{{Out}}
<pre>Rostt Cod is progrmming chrstomthy sit.
Line 337:
As has been noted on the Discussion page, this is necessarily a parochial task which depends on the natural language involved being written with vowels and consonants and on what constitutes a vowel in its orthography. w and y are vowels in Welsh, but consonants in English, although y is often used as a vowel in English too, as it is in other languages. The code below demonstrates how AppleScript might remove the five English vowels and their diacritical forms from a Latinate text. AppleScript can be made to "ignore" diacriticals and case in string comparisons, but not to ignore ligatures or other variations which aren't strictly speaking diacriticals, such as ø. These would need to be included in the vowel list explicitly.
 
<langsyntaxhighlight lang="applescript">-- Bog-standard AppleScript global-search-and-replace handler.
-- searchText can be either a single string or a list of strings to be replaced with replacementText.
on replace(mainText, searchText, replacementText)
Line 363:
set devowelledText to replace(txt, {"a", "e", "i", "o", "u"}, "")
end ignoring
return devowelledText</langsyntaxhighlight>
 
{{output}}
<langsyntaxhighlight AppleScriptlang="applescript">"Th qck brwn fx jmps vr th lzy dg
L'œvr d'n lv
vn Dijk
Line 373:
Jř Blhlvk cndcts Mrtn
P c pn tk brzczy w gszcz?
Mhdv"</langsyntaxhighlight>
 
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">str: "Remove vowels from a string"
 
print str -- split "aeiouAEIOU"</langsyntaxhighlight>
 
{{out}}
Line 386:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">str := "The quick brown fox jumps over the lazy dog"
for i, v in StrSplit("aeiou")
str := StrReplace(str, v)
MsgBox % str</langsyntaxhighlight>
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
===RegEx Version===
<langsyntaxhighlight AutoHotkeylang="autohotkey">str := "The quick brown fox jumps over the lazy dog"
MsgBox % str := RegExReplace(str, "i)[aeiou]")</langsyntaxhighlight>
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f REMOVE_VOWELS_FROM_A_STRING.AWK
BEGIN {
Line 413:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 425:
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
<syntaxhighlight lang="gwbasic">S$ = "Remove a defined subset of glyphs from a string."</syntaxhighlight>
<syntaxhighlight lang="gwbasic">N$ = "": IF LEN (S$) THEN FOR I = 1 TO LEN (S$):C$ = MID$ (S$,I,1):K = ASC (C$):K$ = CHR$ (K - 32 * (K > 95)):V = 0: FOR C = 1 TO 5:V = V + ( MID$ ("AEIOU",C,1) = K$): NEXT C:N$ = N$ + MID$ (C$,V + 1): NEXT I: PRINT N$;</syntaxhighlight>
{{out}}
<pre>
Rmv dfnd sbst f glyphs frm strng.
</pre>
==={{header|BASIC256}}===
<langsyntaxhighlight BASIC256lang="basic256">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + " or how many pickled peppers did Peter Piper pick?"
textofinal$ = ""
 
Line 440 ⟶ 447:
 
print textofinal$
end</langsyntaxhighlight>
 
==={{header|PureBasic}}===
<langsyntaxhighlight PureBasiclang="purebasic">OpenConsole()
mensaje.s = "If Peter Piper picked a pack of pickled peppers" + " or how many pickled peppers did Peter Piper pick?"
textofinal.s = ""
Line 459 ⟶ 466:
PrintN(textofinal)
Input()
CloseConsole()</langsyntaxhighlight>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<langsyntaxhighlight QBasiclang="qbasic">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + ", how many pickled peppers did Peter Piper pick?"
textofinal$ = ""
 
Line 478 ⟶ 485:
 
print textofinal$
end</langsyntaxhighlight>
 
==={{header|Yabasic}}===
<langsyntaxhighlight lang="yabasic">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + " : case how many pickled peppers did Peter Piper pick?"
textofinal$ = ""
 
Line 495 ⟶ 502:
 
print textofinal$
end</langsyntaxhighlight>
 
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let vowel(c) = valof
Line 519 ⟶ 526:
 
let start() be
writes(devowel("THE QUICK BROWN FOX jumps over the lazy dog.*N"))</langsyntaxhighlight>
{{out}}
<pre>TH QCK BRWN FX jmps vr th lzy dg.</pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">Devowel ← ¬∘∊⟜"AaEeIiOoUu"⊸/</syntaxhighlight>
 
=={{header|C}}==
{{trans|Go}}
<langsyntaxhighlight lang="c">#include <stdio.h>
 
void print_no_vowels(const char *s) {
Line 559 ⟶ 569:
test("C Programming Language");
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>Input : C Programming Language
Line 565 ⟶ 575:
 
=={{header|C#}}==
<langsyntaxhighlight lang="csharp">static string remove_vowels(string value)
{
var stripped = from c in value.ToCharArray()
Line 584 ⟶ 594:
test("CSharp Programming Language");
}
</syntaxhighlight>
</lang>
{{out}}
<pre>Input: CSharp Programming Language
Line 590 ⟶ 600:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <algorithm>
#include <iostream>
 
Line 636 ⟶ 646:
test("C++ Programming Language");
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>Input : C++ Programming Language
Line 643 ⟶ 653:
=={{header|Common Lisp}}==
 
<langsyntaxhighlight lang="lisp">(defun vowel-p (c &optional (vowels "aeiou"))
(and (characterp c) (characterp (find c vowels :test #'char-equal))))
 
(defun remove-vowels (s)
(and (stringp s) (remove-if #'vowel-p s)))</langsyntaxhighlight>
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
include "strings.coh";
 
Line 680 ⟶ 690:
CopyString(str, &buf[0]); # make a copy of the string into writeable memory
Devowel(&buf[0]); # remove the vowels
print(&buf[0]); # print the result </langsyntaxhighlight>
 
{{out}}
Line 687 ⟶ 697:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.stdio;
 
void print_no_vowels(string s) {
Line 704 ⟶ 714:
void main() {
print_no_vowels("D Programming Language");
}</langsyntaxhighlight>
{{out}}
<pre>D Prgrmmng Lngg</pre>
Line 710 ⟶ 720:
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Remove_vowels_from_a_string;
 
Line 743 ⟶ 753:
end.
 
</syntaxhighlight>
</lang>
 
{{out}}
Line 750 ⟶ 760:
After: Th qck brwn fx jmps vr th lzy dg
</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
func$ rmv s$ .
for c$ in strchars s$
if strpos "AEIOUaeiou" c$ <> 0
c$ = ""
.
r$ &= c$
.
return r$
.
print rmv "The Quick Brown Fox Jumped Over the Lazy Dog's Back"
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
let stripVowels n=let g=set['a';'e';'i';'o';'u';'A';'E';'I';'O';'U'] in n|>Seq.filter(fun n->not(g.Contains n))|>Array.ofSeq|>System.String
printfn "%s" (stripVowels "Nigel Galloway")
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 762 ⟶ 786:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: formatting kernel sets ;
 
: without-vowels ( str -- new-str ) "aeiouAEIOU" without ;
 
"Factor Programming Language" dup without-vowels
" Input string: %s\nWithout vowels: %s\n" printf</langsyntaxhighlight>
{{out}}
<pre>
Line 775 ⟶ 799:
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">: VOWELS ( -- add len ) S" aeiouAEIOU" ;
 
: VALIDATE ( char addr len -- 0|n) ROT SCAN NIP ; \ find char in string
Line 791 ⟶ 815:
THEN
LOOP
PAD COUNT ;</langsyntaxhighlight>
{{out}}
<pre>
Line 800 ⟶ 824:
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran">
program remove_vowels
implicit none
Line 825 ⟶ 849:
end subroutine print_no_vowels
end program remove_vowels
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 835 ⟶ 859:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight FreeBASIClang="freebasic">dim as string message = "If Peter Piper picked a pack of pickled peppers"+_
", how many pickled peppers did Peter Piper pick?"
dim as string outstr = "", c
Line 849 ⟶ 873:
next i
 
print outstr</langsyntaxhighlight>
 
=={{header|Free Pascal}}==
''See also [[#Pascal|Pascal]]''
{{libheader|strUtils}}
<langsyntaxhighlight lang="pascal">{$longStrings on}
uses
strUtils;
Line 867 ⟶ 891:
end;
writeLn(line)
end.</langsyntaxhighlight>
 
=={{header|Frink}}==
<syntaxhighlight lang="frink">s = """Rosetta Code is a programming chrestomathy site.
The idea is to present solutions to the same
task in as many different languages as possible,
to demonstrate how languages are similar and
different, and to aid a person with a grounding
in one approach to a problem in learning another."""
 
println[s =~ %s/[aeiou]//gi ]</syntaxhighlight>
{{out}}
<pre>
Rstt Cd s prgrmmng chrstmthy st.
Th d s t prsnt sltns t th sm
tsk n s mny dffrnt lnggs s pssbl,
t dmnstrt hw lnggs r smlr nd
dffrnt, nd t d prsn wth grndng
n n pprch t prblm n lrnng nthr.
</pre>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Remove_vowels_from_a_string}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Remove vowels from a string 01.png]]
In '''[https://formulae.org/?example=Remove_vowels_from_a_string this]''' page you can see the program(s) related to this task and their results.
 
[[File:Fōrmulæ - Remove vowels from a string 02.png]]
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">window 1, @"Remove vowels from a string"
 
local fn StringByRemovingVowels( string as CFStringRef ) as CFStringRef
end fn = fn ArrayComponentsJoinedByString( fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetWithCharactersInString( @"aeiou" ) ), @"" )
 
print fn StringByRemovingVowels( @"The quick brown fox jumps over the lazy dog." )
print fn StringByRemovingVowels( @"FutureBasic is a great programming language!" )
 
HandleEvents</syntaxhighlight>
{{out}}
<pre>
Th qck brwn fx jmps vr th lzy dg.
FtrBsc s grt prgrmmng lngg!
</pre>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 900 ⟶ 961:
fmt.Println("Input :", s)
fmt.Println("Output :", removeVowels(s))
}</langsyntaxhighlight>
 
{{out}}
Line 912 ⟶ 973:
Removing three specific Anglo-Saxon vowels from a text, using a general method which can apply to any specific subset of glyphs.
 
<langsyntaxhighlight lang="haskell">------ REMOVE A SPECIFIC SUBSET OF GLYPHS FROM A STRING ----
exceptGlyphs :: String -> String -> String
Line 929 ⟶ 990:
main :: IO ()
main = putStrLn $ exceptGlyphs "eau" txt</langsyntaxhighlight>
 
or, in terms of filter:
<lang haskell>exceptGlyphs :: String -> String -> String
exceptGlyphs = filter . flip notElem</lang>
 
{{Out}}
Line 942 ⟶ 999:
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
 
=={{header|J}}==
<syntaxhighlight lang="j">devowel =: -. & 'aeiouAEIOU'</syntaxhighlight>
 
=={{header|Java}}==
You can use the ''String.replaceAll'' method, which takes a regular expression as it's first argument.
<lang java>public static String removeVowelse(String str){
<syntaxhighlight lang="java">
"rosettacode.org".replaceAll("(?i)[aeiou]", "");
</syntaxhighlight>
<br />
Or
<syntaxhighlight lang="java">public static String removeVowelse(String str){
String re = "";
char c;
Line 953 ⟶ 1,019:
}
return re;
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
Line 961 ⟶ 1,027:
( ''Pace'' Jamie Zawinski, some people, when confronted with a problem, think "I know, I'll use '''parser combinators'''." )
 
<langsyntaxhighlight lang="javascript">(() => {
'use strict'
 
Line 1,224 ⟶ 1,290:
// main ---
return main();
})();</langsyntaxhighlight>
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,236 ⟶ 1,302:
but a filter is all we need here:
 
<langsyntaxhighlight lang="javascript">(() => {
'use strict';
 
Line 1,260 ⟶ 1,326:
// main ---
return main();
})();</langsyntaxhighlight>
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,268 ⟶ 1,334:
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">DEFINE unvowel == ["AaEeIiOoUu" in not] filter.
 
"Remove ALL vowels from this input!" unvowel putchars.</syntaxhighlight>
{{out}}
<pre>Rmv LL vwls frm ths npt!</pre>
 
=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang="sh">
<lang sh>
#!/bin/bash
 
Line 1,306 ⟶ 1,379:
 
input | jq -Rr --arg v "$vowels" 'gsub("[\($v)]+"; ""; "i")'
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,336 ⟶ 1,409:
=={{header|Julia}}==
Unicode sensitive, using the Raku version example text.
<langsyntaxhighlight lang="julia">const ALLVOWELS = Dict(ch => 1 for ch in Vector{Char}("AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰ"))
const ALLVOWELSY = Dict(ch => 1 for ch in Vector{Char}("AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰYẙỲỴỶỸŶŸÝ"))
 
Line 1,353 ⟶ 1,426:
println("Removing vowels from:\n$testtext\n becomes:\n",
String(filter(!isvowel, Vector{Char}(testtext))))
</langsyntaxhighlight>{{out}}
<pre>
Removing vowels from:
Line 1,374 ⟶ 1,447:
dctn shll b fr, t lst n th lmntry nd fndmntl stgs.
</pre>
 
=={{header|K}}==
{{works with|ngn/k}}
<syntaxhighlight lang=K>novowel: {x^"aeiouAEIOU"}
 
novowel"The Quick Brown Fox Jumped Over the Lazy Dog's Back"
"Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck"
</syntaxhighlight>
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">fun removeVowels(s: String): String {
val re = StringBuilder()
for (c in s) {
Line 1,392 ⟶ 1,473:
fun main() {
println(removeVowels("Kotlin Programming Language"))
}</langsyntaxhighlight>
{{out}}
<pre>Ktln Prgrmmng Lngg</pre>
 
=={{header|Lambdatalk}}==
<syntaxhighlight lang="scheme">
<lang Scheme>
'{S.replace [aeiouy]* by in
Rosetta Code is a programming chrestomathy site.
Line 1,407 ⟶ 1,488:
 
-> Rstt Cd s prgrmmng chrstmth st. Th d s t prsnt sltns t th sm tsk n s mn dffrnt lnggs s pssbl, t dmnstrt hw lnggs r smlr nd dffrnt, nd t d prsn wth grndng n n pprch t prblm n lrnng nthr.
</syntaxhighlight>
</lang>
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">function removeVowels (inStr)
local outStr, letter = ""
local vowels = "AEIUOaeiou"
Line 1,425 ⟶ 1,506:
 
local testStr = "The quick brown fox jumps over the lazy dog"
print(removeVowels(testStr))</langsyntaxhighlight>
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
Line 1,433 ⟶ 1,514:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">StringReplace["The Quick Brown Fox Jumped Over the Lazy Dog's Back", (Alternatives @@ Characters["aeiou"]) -> ""]</langsyntaxhighlight>
{{out}}
<pre>Th Qck Brwn Fx Jmpd Ovr th Lzy Dg's Bck</pre>
 
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab">
<lang Matlab>
function [result] = remove_vowels(text)
% http://rosettacode.org/wiki/Remove_vowels_from_a_string
Line 1,456 ⟶ 1,537:
%!test
%! assert(remove_vowels('The quick brown fox jumps over the lazy dog'),'Th qck brwn fx jmps vr th lzy dg')
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,465 ⟶ 1,546:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils, sugar
 
const Vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
Line 1,480 ⟶ 1,561:
const TestString = "The quick brown fox jumps over the lazy dog"
echo TestString
echo TestString.dup(removeVowels(Vowels))</langsyntaxhighlight>
 
{{out}}
<pre>The quick brown fox jumps over the lazy dog
Th qck brwn fx jmps vr th lzy dg</pre>
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let remove_vowels s : string =
let not_vowel = Fun.negate (String.contains "AaEeIiOoUu") in
String.to_seq s |> Seq.filter not_vowel |> String.of_seq</syntaxhighlight>
 
=={{header|Pascal}}==
''See also [[#Delphi|Delphi]] or [[#Free Pascal|Free Pascal]]''<br/>
This program works with any ISO 7185 compliant compiler.
<langsyntaxhighlight lang="pascal">program removeVowelsFromString(input, output);
 
const
Line 1,563 ⟶ 1,649:
end;
writeLn
end.</langsyntaxhighlight>
{{in}}
The quick brown fox jumps over the lazy dog.
Line 1,571 ⟶ 1,657:
{{works with|Extended Pascal}}
More convenient though is to use some Extended Pascal (ISO 10206) features:
<langsyntaxhighlight lang="pascal">program removeVowelsFromString(input, output);
const
vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'];
Line 1,591 ⟶ 1,677:
writeLn(disemvoweledLine)
end.</langsyntaxhighlight>
{{in}}
The quick brown fox jumps over the lazy dog.
Line 1,599 ⟶ 1,685:
=={{header|Perl}}==
Inspired by the Raku entry.
<langsyntaxhighlight lang="perl">use strict;
use warnings;
use utf8;
Line 1,618 ⟶ 1,704:
my @vowels;
chr($_) =~ /[aæeiıoœu]/i and push @vowels, chr($_) for 0x20 .. 0x1ff;
print NFD($_) =~ /@{[join '|', @vowels]}/ ? ' ' : $_ for split /(\X)/, $text;</langsyntaxhighlight>
{{out}}
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
Line 1,630 ⟶ 1,716:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">constant</span> <span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"Phix Programming Language"</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Input : %s\nOutput : %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"out"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"aeiouAEIUO"</span><span style="color: #0000FF;">)})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,640 ⟶ 1,726:
</pre>
If you want something a bit more like Julia/Raku, the following should work, but you have to provide your own vowel-set, or nick/merge from Julia/REXX
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 1,665 ⟶ 1,751:
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">remove_vowels</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">))</span>
<!--</langsyntaxhighlight>-->
(output deliberately not shown due to windows console effects, but it is the same as Raku, or Julia with the alternate find/replace line.)
 
=={{header|Picat}}==
<langsyntaxhighlight Picatlang="picat">main =>
println("The Quick Brown Fox Jumped Over the Lazy Dog's Back".remove_vowels),
println("Picat programming language".remove_vowels).
 
remove_vowels(S) = [C : C in S, not membchk(C,"AEIOUaeiou")].</langsyntaxhighlight>
 
{{out}}
Line 1,684 ⟶ 1,770:
 
 
<syntaxhighlight lang="prolog">
<lang Prolog>
:- system:set_prolog_flag(double_quotes,chars) .
 
Line 1,721 ⟶ 1,807:
lists:member(CHAR,"AEIOUaeiouüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ")
.
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,747 ⟶ 1,833:
 
{{works with|Python|3.7|}}
<langsyntaxhighlight lang="python">'''Remove a defined subset of glyphs from a string'''
 
 
Line 1,782 ⟶ 1,868:
# MAIN ---
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,793 ⟶ 1,879:
===One liner===
Well, almost........
<syntaxhighlight lang="python">
<lang Python>
txt = '''
Rosetta Code is a programming chrestomathy site.
Line 1,803 ⟶ 1,889:
 
print(''.join(list(filter(lambda a: a not in "aeiou",txt))))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,815 ⟶ 1,901:
 
=={{header|Quackery}}==
<langsyntaxhighlight Quackerylang="quackery">[ 0 $ "AEIOUaeiou"
witheach
[ bit | ] ] constant is vowels ( --> f )
Line 1,826 ⟶ 1,912:
$ '"Beautiful coquettes are quacks of love."'
$ ' -- Francois De La Rochefoucauld' join
disemvowel echo$</langsyntaxhighlight>
 
'''Output:'''
Line 1,844 ⟶ 1,930:
Strings from http://mylanguages.org/. No affiliation, but it's a nice resource. (note: these are not all the same sentence but are all from the same paragraph. They frankly were picked based on their vowel load.)
 
<syntaxhighlight lang="raku" perl6line>my @vowels = (0x20 .. 0x2fff).map: { .chr if .chr.samemark('x') ~~ m:i/<[aæeiıoœu]>/ }
 
my $text = q:to/END/;
Line 1,857 ⟶ 1,943:
END
 
put $text.subst(/@vowels/, ' ', :g);</langsyntaxhighlight>
{{out}}
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
Line 1,873 ⟶ 1,959:
=== using the TRANSLATE BIF ===
This REXX version uses the &nbsp; '''translate''' &nbsp; BIF which works faster for longer strings as there is no character-by-character manipulation.
<langsyntaxhighlight lang="rexx">/*REXX program removes vowels (both lowercase and uppercase and accented) from a string.*/
parse arg x /*obtain optional argument from the CL.*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
Line 1,883 ⟶ 1,969:
y= space(translate(y, , vowels), 0) /*trans. vowels──►blanks, elide blanks.*/
y= translate(y, , q) /*trans the Q characters back to blanks*/
say 'output string: ' y /*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
Line 1,892 ⟶ 1,978:
=== using character eliding ===
This REXX version uses a character-by-character manipulation and should be easier to understand.
<langsyntaxhighlight lang="rexx">/*REXX program removes vowels (both lowercase and uppercase and accented) from a string.*/
parse arg x /*obtain optional argument from the CL.*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
Line 1,906 ⟶ 1,992:
 
x= substr(x, 2) /*elide the prefixed dummy character. */
say 'output string: ' x /*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; is identical to the 1<sup>st</sup> REXX version.}} <br><br>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
load "stdlib.ring"
str = "Ring Programming Language"
Line 1,920 ⟶ 2,006:
next
see "String without vowels: " + str + nl
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,926 ⟶ 2,012:
String without vowels: Rng Prgrmmng Lngg
</pre>
=={{header|RPL}}==
≪ "AEIOUaeiou" → string vowels
≪ "" 1 string SIZE '''FOR''' j
string j DUP SUB
'''IF''' vowels OVER POS '''THEN''' DROP '''ELSE''' + '''END'''
'''NEXT'''
≫ ≫ ''''NOVWL'''' STO
{{in}}
<pre>
"This is a difficult sentence to pronounce" NOVWL
</pre>
{{out}}
<pre>
1: "Ths s dffclt sntnc t prnnc"
</pre>
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">
p "Remove vowels from a string".delete("aeiouAEIOU") # => "Rmv vwls frm strng"
</syntaxhighlight>
</lang>
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">
fn remove_vowels(str: String) -> String {
let vowels = "aeiouAEIOU";
Line 1,953 ⟶ 2,055:
println!("{}", remove_vowels(intro));
}
</syntaxhighlight>
</lang>
Output :
<pre>
Line 1,959 ⟶ 2,061:
Frrs, th crb, s th nffcl msct f th Rst Prgrmmng Lngg
</pre>
 
=={{header|sed}}==
<syntaxhighlight lang="sed">s/[AaEeIiOoUu]//g</syntaxhighlight>
 
=={{header|Smalltalk}}==
<langsyntaxhighlight lang="smalltalk">in := 'The balloon above harsh waters of programming languages, is the mascot of Smalltalk'.
out := in reject:[:ch | ch isVowel].
in printCR.
out printCR.</langsyntaxhighlight>
{{out}}
<pre>The balloon above harsh harsh waters of programming languages, is the mascot of Smalltalk
Line 1,970 ⟶ 2,075:
 
As usual, there are many alternative ways to do this:
<langsyntaxhighlight lang="smalltalk">out := in reject:#isVowel. " cool: symbols understand value: "
 
out := in select:[:ch | ch isVowel not].
Line 1,984 ⟶ 2,089:
ch isVowel ifFalse:[ s nextPut:ch ]
]]
</syntaxhighlight>
</lang>
 
=={{header|Standard ML}}==
<langsyntaxhighlight lang="sml">fun isVowel c =
CharVector.exists (fn v => c = v) "AaEeIiOoUu"
 
Line 1,995 ⟶ 2,100:
val str = "LOREM IPSUM dolor sit amet\n"
val () = print str
val () = print (removeVowels str)</langsyntaxhighlight>
{{out}}
<pre>LOREM IPSUM dolor sit amet
Line 2,001 ⟶ 2,106:
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">func isVowel(_ char: Character) -> Bool {
switch (char) {
case "a", "A", "e", "E", "i", "I", "o", "O", "u", "U":
Line 2,016 ⟶ 2,121:
let str = "The Swift Programming Language"
print(str)
print(removeVowels(string: str))</langsyntaxhighlight>
 
{{out}}
Line 2,025 ⟶ 2,130:
 
=={{header|Visual Basic .NET}}==
<langsyntaxhighlight lang="vbnet">Imports System.Text
 
Module Module1
Line 2,055 ⟶ 2,160:
End Sub
 
End Module</langsyntaxhighlight>
{{out}}
<pre>Input : Visual Basic .NET
Output : Vsl Bsc .NT</pre>
 
=={{header|V (Vlang)}}==
{{trans|AutoHotkey}}
 
<syntaxhighlight lang="v (vlang)">fn main() {
mut str := 'The quick brown fox jumps over the lazy dog'
for val in 'aeiou'.split('') {str = str.replace(val,'')}
println(str)
}</syntaxhighlight>
 
{{out}}
<pre>
Th qck brwn fx jmps vr th lzy dg
</pre>
 
=={{header|Wren}}==
<langsyntaxhighlight ecmascriptlang="wren">var removeVowels = Fn.new { |s| s.where { |c| !"aeiouAEIOU".contains(c) }.join() }
 
var s = "Wren Programming Language"
System.print("Input : %(s)")
System.print("Output : %(removeVowels.call(s))")</langsyntaxhighlight>
 
{{out}}
Line 2,074 ⟶ 2,193:
 
=={{header|XBS}}==
<langsyntaxhighlight lang="xbs">func RemoveVowels(x:string):string{
set Vowels:array="aeiou"::split();
set nx:string="";
Line 2,088 ⟶ 2,207:
}
 
log(RemoveVowels("Hello, world!"));</langsyntaxhighlight>
{{out}}
<pre>
Line 2,095 ⟶ 2,214:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">string 0; \make strings zero-terminated
 
func Disemvowel(S); \remove vowels from string
Line 2,109 ⟶ 2,228:
];
 
Text(0, Disemvowel("pack my box with FIVE DOZEN LIQUOR JUGS!"))</langsyntaxhighlight>
 
Output:
Line 2,117 ⟶ 2,236:
 
=={{header|XProfan}}==
<syntaxhighlight lang="xprofan">cls
<lang XProfan>cls
Set("RegEx",1)
Var string e = "The quick brown fox jumps over the lazy dog"
Var string a = Translate$(e,"(?i)[aeiou]","")
MessageBox("Input : "+e+"\nOutput: "+a,"Remove vowels",1)
End</langsyntaxhighlight>
{{out}}
<pre>
1,983

edits