Remove vowels from a string: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
 
(45 intermediate revisions by 24 users not shown)
Line 9: Line 9:
{{trans|Python}}
{{trans|Python}}


<lang 11l>F exceptGlyphs(exclusions, s)
<syntaxhighlight lang="11l">F exceptGlyphs(exclusions, s)
R s.filter(c -> c !C @exclusions).join(‘’)
R s.filter(c -> c !C @exclusions).join(‘’)


Line 20: Line 20:
in one approach to a problem in learning another.’
in one approach to a problem in learning another.’


print(exceptGlyphs(‘eau’, txt))</lang>
print(exceptGlyphs(‘eau’, txt))</syntaxhighlight>


{{out}}
{{out}}
Line 35: Line 35:
=={{header|8080 Assembly}}==
=={{header|8080 Assembly}}==


<lang 8080asm> org 100h
<syntaxhighlight lang="8080asm"> org 100h
jmp demo
jmp demo
;;; Remove the vowels from the $-terminated string at [DE]
;;; Remove the vowels from the $-terminated string at [DE]
Line 65: Line 65:
mvi c,9 ; Print using CP/M
mvi c,9 ; Print using CP/M
jmp 5
jmp 5
string: db 'THE QUICK BROWN FOX jumps over the lazy dog$'</lang>
string: db 'THE QUICK BROWN FOX jumps over the lazy dog$'</syntaxhighlight>


{{out}}
{{out}}


<pre>TH QCK BRWN FX jmps vr th lzy dg</pre>
<pre>TH QCK BRWN FX jmps vr th lzy dg</pre>

=={{header|Action!}}==
<syntaxhighlight lang="action!">BYTE FUNC IsVovel(CHAR c)
CHAR ARRAY vovels="AEIOUaeiou"
BYTE i

FOR i=1 TO vovels(0)
DO
IF vovels(i)=c THEN
RETURN (1)
FI
OD
RETURN (0)

PROC RemoveVovels(CHAR ARRAY s,res)
BYTE i
CHAR c

res(0)=0
FOR i=1 TO s(0)
DO
c=s(i)
IF IsVovel(c)=0 THEN
res(0)==+1
res(res(0))=c
FI
OD
RETURN

PROC Test(CHAR ARRAY s)
CHAR ARRAY res(256)

RemoveVovels(s,res)
PrintE("Input:") PrintE(s)
PrintE("Output:") PrintE(res)
RETURN

PROC Main()
Test("The Quick Brown Fox Jumped Over the Lazy Dog's Back")
Test("Action! is a programming language for Atari 8-bit computer.")
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Remove_vowels_from_a_string.png Screenshot from Atari 8-bit computer]
<pre>
Input:
The Quick Brown Fox Jumped Over the Lazy Dog's Back
Output:
Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck

Input:
Action! is a programming language for Atari 8-bit computer.
Output:
ctn! s prgrmmng lngg fr tr 8-bt cmptr.
</pre>


=={{header|Ada}}==
=={{header|Ada}}==
<lang Ada>with Ada.Text_IO; use Ada.Text_IO;
<syntaxhighlight lang="ada">with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;


Line 102: Line 156:
Put_Line (NV2);
Put_Line (NV2);
end Main;
end Main;
</syntaxhighlight>
</lang>
{{output}}
{{output}}
<pre>
<pre>
Line 113: Line 167:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
<lang algol68>BEGIN
<syntaxhighlight lang="algol68">BEGIN
# returns s with the vowels removed #
# returns s with the vowels removed #
OP DEVOWEL = ( STRING s )STRING:
OP DEVOWEL = ( STRING s )STRING:
Line 137: Line 191:
test devowel( "abcdefghijklmnoprstuvwxyz" );
test devowel( "abcdefghijklmnoprstuvwxyz" );
test devowel( "Algol 68 Programming Language" )
test devowel( "Algol 68 Programming Language" )
END</lang>
END</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 148: Line 202:


=={{header|APL}}==
=={{header|APL}}==
<lang APL>devowel ← ~∘'AaEeIiOoUu'</lang>
<syntaxhighlight lang="apl">devowel ← ~∘'AaEeIiOoUu'</syntaxhighlight>
{{out}}
{{out}}
<pre> devowel 'THE QUICK BROWN FOX jumps over the lazy dog'
<pre> devowel 'THE QUICK BROWN FOX jumps over the lazy dog'
Line 163: Line 217:
We can also improve productivity by using library functions whenever feasible.
We can also improve productivity by using library functions whenever feasible.


<lang applescript>------- REMOVE A DEFINED SUBSET OF GLYPHS FROM A TEXT ------
<syntaxhighlight lang="applescript">------- REMOVE A DEFINED SUBSET OF GLYPHS FROM A TEXT ------


-- exceptGlyphs :: String -> String -> Bool
-- exceptGlyphs :: String -> String -> Bool
Line 270: Line 324:
set my text item delimiters to dlm
set my text item delimiters to dlm
s
s
end unlines</lang>
end unlines</syntaxhighlight>
{{Out}}
{{Out}}
<pre>Rostt Cod is progrmming chrstomthy sit.
<pre>Rostt Cod is progrmming chrstomthy sit.
Line 283: 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.
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.


<lang applescript>-- Bog-standard AppleScript global-search-and-replace handler.
<syntaxhighlight 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.
-- searchText can be either a single string or a list of strings to be replaced with replacementText.
on replace(mainText, searchText, replacementText)
on replace(mainText, searchText, replacementText)
Line 309: Line 363:
set devowelledText to replace(txt, {"a", "e", "i", "o", "u"}, "")
set devowelledText to replace(txt, {"a", "e", "i", "o", "u"}, "")
end ignoring
end ignoring
return devowelledText</lang>
return devowelledText</syntaxhighlight>


{{output}}
{{output}}
<lang AppleScript>"Th qck brwn fx jmps vr th lzy dg
<syntaxhighlight lang="applescript">"Th qck brwn fx jmps vr th lzy dg
L'œvr d'n lv
L'œvr d'n lv
vn Dijk
vn Dijk
Line 319: Line 373:
Jř Blhlvk cndcts Mrtn
Jř Blhlvk cndcts Mrtn
P c pn tk brzczy w gszcz?
P c pn tk brzczy w gszcz?
Mhdv"</lang>
Mhdv"</syntaxhighlight>


=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>str: "Remove vowels from a string"
<syntaxhighlight lang="rebol">str: "Remove vowels from a string"


print str -- split "aeiouAEIOU"</lang>
print str -- split "aeiouAEIOU"</syntaxhighlight>


{{out}}
{{out}}
Line 332: Line 386:


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>str := "The quick brown fox jumps over the lazy dog"
<syntaxhighlight lang="autohotkey">str := "The quick brown fox jumps over the lazy dog"
for i, v in StrSplit("aeiou")
for i, v in StrSplit("aeiou")
str := StrReplace(str, v)
str := StrReplace(str, v)
MsgBox % str</lang>
MsgBox % str</syntaxhighlight>
{{out}}
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
===RegEx Version===
===RegEx Version===
<lang AutoHotkey>str := "The quick brown fox jumps over the lazy dog"
<syntaxhighlight lang="autohotkey">str := "The quick brown fox jumps over the lazy dog"
MsgBox % str := RegExReplace(str, "i)[aeiou]")</lang>
MsgBox % str := RegExReplace(str, "i)[aeiou]")</syntaxhighlight>
{{out}}
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
<pre>Th qck brwn fx jmps vr th lzy dg</pre>


=={{header|AWK}}==
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f REMOVE_VOWELS_FROM_A_STRING.AWK
# syntax: GAWK -f REMOVE_VOWELS_FROM_A_STRING.AWK
BEGIN {
BEGIN {
Line 359: Line 413:
exit(0)
exit(0)
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 368: Line 422:
new: Th qck brwn fx jmps vr th lzy dg
new: Th qck brwn fx jmps vr th lzy dg
</pre>
</pre>


=={{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}}===
<syntaxhighlight lang="basic256">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + " or how many pickled peppers did Peter Piper pick?"
textofinal$ = ""

for i = 1 to length(mensaje$)
c$ = mid(mensaje$,i,1)
begin case
case lower(c$) = "a" or lower(c$) = "e" or lower(c$) = "i" or lower(c$) = "o" or lower(c$) = "u"
continue for
else
textofinal$ += c$
end case
next i

print textofinal$
end</syntaxhighlight>

==={{header|PureBasic}}===
<syntaxhighlight lang="purebasic">OpenConsole()
mensaje.s = "If Peter Piper picked a pack of pickled peppers" + " or how many pickled peppers did Peter Piper pick?"
textofinal.s = ""

For i.i = 1 To Len(mensaje)
c.s = Mid(mensaje,i,1)
Select c
Case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U"
Continue
Default
textofinal + c
EndSelect
Next i

PrintN(textofinal)
Input()
CloseConsole()</syntaxhighlight>

==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + ", how many pickled peppers did Peter Piper pick?"
textofinal$ = ""

for i = 1 to len(mensaje$)
c$ = mid$(mensaje$, i, 1)
select case c$
case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U"
REM continue for
case else
textofinal$ = textofinal$ + c$
end select
next i

print textofinal$
end</syntaxhighlight>

==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + " : case how many pickled peppers did Peter Piper pick?"
textofinal$ = ""

for i = 1 to len(mensaje$)
c$ = mid$(mensaje$,i,1)
switch c$
case "a" : case "e" : case "i" : case "o" : case "u" : case "A" : case "E" : case "I" : case "O" : case "U"
continue
default
textofinal$ = textofinal$ + c$
end switch
next i

print textofinal$
end</syntaxhighlight>


=={{header|BCPL}}==
=={{header|BCPL}}==
<lang bcpl>get "libhdr"
<syntaxhighlight lang="bcpl">get "libhdr"


let vowel(c) = valof
let vowel(c) = valof
Line 389: Line 526:


let start() be
let start() be
writes(devowel("THE QUICK BROWN FOX jumps over the lazy dog.*N"))</lang>
writes(devowel("THE QUICK BROWN FOX jumps over the lazy dog.*N"))</syntaxhighlight>
{{out}}
{{out}}
<pre>TH QCK BRWN FX jmps vr th lzy dg.</pre>
<pre>TH QCK BRWN FX jmps vr th lzy dg.</pre>

=={{header|BQN}}==
<syntaxhighlight lang="bqn">Devowel ← ¬∘∊⟜"AaEeIiOoUu"⊸/</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
{{trans|Go}}
{{trans|Go}}
<lang c>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>


void print_no_vowels(const char *s) {
void print_no_vowels(const char *s) {
Line 429: Line 569:
test("C Programming Language");
test("C Programming Language");
return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Input : C Programming Language
<pre>Input : C Programming Language
Line 435: Line 575:


=={{header|C#}}==
=={{header|C#}}==
<lang csharp>static string remove_vowels(string value)
<syntaxhighlight lang="csharp">static string remove_vowels(string value)
{
{
var stripped = from c in value.ToCharArray()
var stripped = from c in value.ToCharArray()
Line 454: Line 594:
test("CSharp Programming Language");
test("CSharp Programming Language");
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>Input: CSharp Programming Language
<pre>Input: CSharp Programming Language
Line 460: Line 600:


=={{header|C++}}==
=={{header|C++}}==
<lang cpp>#include <algorithm>
<syntaxhighlight lang="cpp">#include <algorithm>
#include <iostream>
#include <iostream>


Line 506: Line 646:
test("C++ Programming Language");
test("C++ Programming Language");
return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Input : C++ Programming Language
<pre>Input : C++ Programming Language
Line 513: Line 653:
=={{header|Common Lisp}}==
=={{header|Common Lisp}}==


<syntaxhighlight lang="lisp">(defun vowel-p (c &optional (vowels "aeiou"))
<lang lisp>
(and (characterp c) (characterp (find c vowels :test #'char-equal))))
(defun vowelp (c &key (vowels "aeiou"))
(and (characterp c) (find c vowels :test #'char-equal)))


(defun remove-vowels (s)
(defun remove-vowels (s)
(remove-if #'vowelp s))
(and (stringp s) (remove-if #'vowel-p s)))</syntaxhighlight>
</lang>


=={{header|Cowgol}}==
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
<syntaxhighlight lang="cowgol">include "cowgol.coh";
include "strings.coh";
include "strings.coh";


Line 552: Line 690:
CopyString(str, &buf[0]); # make a copy of the string into writeable memory
CopyString(str, &buf[0]); # make a copy of the string into writeable memory
Devowel(&buf[0]); # remove the vowels
Devowel(&buf[0]); # remove the vowels
print(&buf[0]); # print the result </lang>
print(&buf[0]); # print the result </syntaxhighlight>


{{out}}
{{out}}
Line 559: Line 697:


=={{header|D}}==
=={{header|D}}==
<lang d>import std.stdio;
<syntaxhighlight lang="d">import std.stdio;


void print_no_vowels(string s) {
void print_no_vowels(string s) {
Line 576: Line 714:
void main() {
void main() {
print_no_vowels("D Programming Language");
print_no_vowels("D Programming Language");
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>D Prgrmmng Lngg</pre>
<pre>D Prgrmmng Lngg</pre>
Line 582: Line 720:
=={{header|Delphi}}==
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| System.SysUtils}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Remove_vowels_from_a_string;
program Remove_vowels_from_a_string;


Line 615: Line 753:
end.
end.


</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 622: Line 760:
After: Th qck brwn fx jmps vr th lzy dg
After: Th qck brwn fx jmps vr th lzy dg
</pre>
</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#}}==
=={{header|F_Sharp|F#}}==
<lang fsharp>
<syntaxhighlight 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
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")
printfn "%s" (stripVowels "Nigel Galloway")
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 634: Line 786:


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor>USING: formatting kernel sets ;
<syntaxhighlight lang="factor">USING: formatting kernel sets ;


: without-vowels ( str -- new-str ) "aeiouAEIOU" without ;
: without-vowels ( str -- new-str ) "aeiouAEIOU" without ;


"Factor Programming Language" dup without-vowels
"Factor Programming Language" dup without-vowels
" Input string: %s\nWithout vowels: %s\n" printf</lang>
" Input string: %s\nWithout vowels: %s\n" printf</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Input string: Factor Programming Language
Input string: Factor Programming Language
Without vowels: Fctr Prgrmmng Lngg
Without vowels: Fctr Prgrmmng Lngg
</pre>

=={{header|Forth}}==
<syntaxhighlight lang="forth">: VOWELS ( -- add len ) S" aeiouAEIOU" ;

: VALIDATE ( char addr len -- 0|n) ROT SCAN NIP ; \ find char in string
: C+! ( n addr ) TUCK C@ + SWAP C! ; \ add n to byte address
: ]PAD ( ndx -- addr ) PAD 1+ + ; \ index into text section
: PAD, ( char -- ) PAD C@ ]PAD C! 1 PAD C+! ; \ compile char into PAD, inc. count

: NOVOWELS ( addr len -- addr' len')
0 PAD C! \ reset byte count
BOUNDS ( -- end start)
?DO
I C@ DUP VOWELS VALIDATE
IF DROP \ don't need vowels
ELSE PAD, \ compile char & incr. byte count
THEN
LOOP
PAD COUNT ;</syntaxhighlight>
{{out}}
<pre>
CREATE TEST$ S" Now is the time for all good men..." S, ok
TEST$ COUNT NOVOWELS CR TYPE
Nw s th tm fr ll gd mn... ok
</pre>
</pre>


=={{header|Fortran}}==
=={{header|Fortran}}==
<lang fortran>
<syntaxhighlight lang="fortran">
program remove_vowels
program remove_vowels
implicit none
implicit none
Line 672: Line 849:
end subroutine print_no_vowels
end subroutine print_no_vowels
end program remove_vowels
end program remove_vowels
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 682: Line 859:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang FreeBASIC>dim as string message = "If Peter Piper picked a pack of pickled peppers"+_
<syntaxhighlight lang="freebasic">dim as string message = "If Peter Piper picked a pack of pickled peppers"+_
", how many pickled peppers did Peter Piper pick?"
", how many pickled peppers did Peter Piper pick?"
dim as string outstr = "", c
dim as string outstr = "", c
Line 696: Line 873:
next i
next i


print outstr</lang>
print outstr</syntaxhighlight>

=={{header|Free Pascal}}==
''See also [[#Pascal|Pascal]]''
{{libheader|strUtils}}
<syntaxhighlight lang="pascal">{$longStrings on}
uses
strUtils;
var
line: string;
c: char;
begin
readLn(line);
for c in ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'] do
begin
line := delChars(line, c)
end;
writeLn(line)
end.</syntaxhighlight>

=={{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æ}}==
=={{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}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 729: Line 961:
fmt.Println("Input :", s)
fmt.Println("Input :", s)
fmt.Println("Output :", removeVowels(s))
fmt.Println("Output :", removeVowels(s))
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 741: Line 973:
Removing three specific Anglo-Saxon vowels from a text, using a general method which can apply to any specific subset of glyphs.
Removing three specific Anglo-Saxon vowels from a text, using a general method which can apply to any specific subset of glyphs.


<syntaxhighlight lang="haskell">------ REMOVE A SPECIFIC SUBSET OF GLYPHS FROM A STRING ----
( ''Pace'' Jamie Kawinski, some people, when confronted with a problem, think "I know, I'll use '''list comprehensions'''." )
<lang haskell>------ REMOVE A SPECIFIC SUBSET OF GLYPHS FROM A STRING ----

exceptGlyphs :: String -> String -> String
exceptGlyphs :: String -> String -> String
exceptGlyphs exclusions s =
exceptGlyphs = filter . flip notElem
[ c
| c <- s
, c `notElem` exclusions ]


---------------------------- TEST --------------------------
---------------------------- TEST --------------------------
txt :: String
txt :: String
Line 759: Line 988:
\different, and to aid a person with a grounding\n\
\different, and to aid a person with a grounding\n\
\in one approach to a problem in learning another."
\in one approach to a problem in learning another."

main :: IO ()
main :: IO ()
main = putStrLn $ exceptGlyphs "eau" txt</lang>
main = putStrLn $ exceptGlyphs "eau" txt</syntaxhighlight>

or, in terms of filter:
<lang haskell>exceptGlyphs :: String -> String -> String
exceptGlyphs = filter . flip notElem</lang>


{{Out}}
{{Out}}
Line 774: Line 999:
diffrnt, nd to id prson with gronding
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
in on pproch to problm in lrning nothr.</pre>

=={{header|J}}==
<syntaxhighlight lang="j">devowel =: -. & 'aeiouAEIOU'</syntaxhighlight>


=={{header|Java}}==
=={{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 = "";
String re = "";
char c;
char c;
Line 785: Line 1,019:
}
}
return re;
return re;
}</lang>
}</syntaxhighlight>


=={{header|JavaScript}}==
=={{header|JavaScript}}==
Line 793: Line 1,027:
( ''Pace'' Jamie Zawinski, some people, when confronted with a problem, think "I know, I'll use '''parser combinators'''." )
( ''Pace'' Jamie Zawinski, some people, when confronted with a problem, think "I know, I'll use '''parser combinators'''." )


<lang javascript>(() => {
<syntaxhighlight lang="javascript">(() => {
'use strict'
'use strict'


Line 1,056: Line 1,290:
// main ---
// main ---
return main();
return main();
})();</lang>
})();</syntaxhighlight>
{{Out}}
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,068: Line 1,302:
but a filter is all we need here:
but a filter is all we need here:


<lang javascript>(() => {
<syntaxhighlight lang="javascript">(() => {
'use strict';
'use strict';


Line 1,092: Line 1,326:
// main ---
// main ---
return main();
return main();
})();</lang>
})();</syntaxhighlight>
{{Out}}
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,100: Line 1,334:
diffrnt, nd to id prson with gronding
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
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}}==
=={{header|jq}}==
{{works with|jq}}
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang="sh">
<lang sh>
#!/bin/bash
#!/bin/bash


Line 1,138: Line 1,379:


input | jq -Rr --arg v "$vowels" 'gsub("[\($v)]+"; ""; "i")'
input | jq -Rr --arg v "$vowels" 'gsub("[\($v)]+"; ""; "i")'
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,168: Line 1,409:
=={{header|Julia}}==
=={{header|Julia}}==
Unicode sensitive, using the Raku version example text.
Unicode sensitive, using the Raku version example text.
<lang julia>const ALLVOWELS = Dict(ch => 1 for ch in Vector{Char}("AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰ"))
<syntaxhighlight 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ẙỲỴỶỸŶŸÝ"))
const ALLVOWELSY = Dict(ch => 1 for ch in Vector{Char}("AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰYẙỲỴỶỸŶŸÝ"))


Line 1,185: Line 1,426:
println("Removing vowels from:\n$testtext\n becomes:\n",
println("Removing vowels from:\n$testtext\n becomes:\n",
String(filter(!isvowel, Vector{Char}(testtext))))
String(filter(!isvowel, Vector{Char}(testtext))))
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Removing vowels from:
Removing vowels from:
Line 1,206: Line 1,447:
dctn shll b fr, t lst n th lmntry nd fndmntl stgs.
dctn shll b fr, t lst n th lmntry nd fndmntl stgs.
</pre>
</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}}==
=={{header|Kotlin}}==
<lang scala>fun removeVowels(s: String): String {
<syntaxhighlight lang="scala">fun removeVowels(s: String): String {
val re = StringBuilder()
val re = StringBuilder()
for (c in s) {
for (c in s) {
Line 1,224: Line 1,473:
fun main() {
fun main() {
println(removeVowels("Kotlin Programming Language"))
println(removeVowels("Kotlin Programming Language"))
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Ktln Prgrmmng Lngg</pre>
<pre>Ktln Prgrmmng Lngg</pre>

=={{header|Lambdatalk}}==
<syntaxhighlight lang="scheme">
'{S.replace [aeiouy]* by in
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.}

-> 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>


=={{header|Lua}}==
=={{header|Lua}}==
<lang lua>function removeVowels (inStr)
<syntaxhighlight lang="lua">function removeVowels (inStr)
local outStr, letter = ""
local outStr, letter = ""
local vowels = "AEIUOaeiou"
local vowels = "AEIUOaeiou"
Line 1,244: Line 1,506:


local testStr = "The quick brown fox jumps over the lazy dog"
local testStr = "The quick brown fox jumps over the lazy dog"
print(removeVowels(testStr))</lang>
print(removeVowels(testStr))</syntaxhighlight>
{{out}}
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
<pre>Th qck brwn fx jmps vr th lzy dg</pre>




=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">StringReplace["The Quick Brown Fox Jumped Over the Lazy Dog's Back", (Alternatives @@ Characters["aeiou"]) -> ""]</syntaxhighlight>
{{out}}
<pre>Th Qck Brwn Fx Jmpd Ovr th Lzy Dg's Bck</pre>


=={{header|MATLAB}} / {{header|Octave}}==
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab">
<lang Matlab>
function [result] = remove_vowels(text)
function [result] = remove_vowels(text)
% http://rosettacode.org/wiki/Remove_vowels_from_a_string
% http://rosettacode.org/wiki/Remove_vowels_from_a_string
Line 1,267: Line 1,537:
%!test
%!test
%! assert(remove_vowels('The quick brown fox jumps over the lazy dog'),'Th qck brwn fx jmps vr th lzy dg')
%! assert(remove_vowels('The quick brown fox jumps over the lazy dog'),'Th qck brwn fx jmps vr th lzy dg')
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,276: Line 1,546:


=={{header|Nim}}==
=={{header|Nim}}==
<lang Nim>import strutils, sugar
<syntaxhighlight lang="nim">import strutils, sugar


const Vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
const Vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
Line 1,291: Line 1,561:
const TestString = "The quick brown fox jumps over the lazy dog"
const TestString = "The quick brown fox jumps over the lazy dog"
echo TestString
echo TestString
echo TestString.dup(removeVowels(Vowels))</lang>
echo TestString.dup(removeVowels(Vowels))</syntaxhighlight>


{{out}}
{{out}}
<pre>The quick brown fox jumps over the lazy dog
<pre>The quick brown fox jumps over the lazy dog
Th qck brwn fx jmps vr th lzy dg</pre>
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.
<syntaxhighlight lang="pascal">program removeVowelsFromString(input, output);

const
stringLength = 80;

type
stringIndex = 1..stringLength;
string = array[stringIndex] of char;

var
sourceIndex, destinationIndex: stringIndex;
line, disemvoweledLine: string;
vowels: set of char;

function lineHasVowels: Boolean;
var
sourceIndex: stringIndex;
vowelIndices: set of stringIndex;
begin
vowelIndices := [];
for sourceIndex := 1 to stringLength do
begin
if line[sourceIndex] in vowels then
begin
vowelIndices := vowelIndices + [sourceIndex]
end
end;
lineHasVowels := vowelIndices <> []
end;

begin
vowels := ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'];
{ - - input - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
for destinationIndex := 1 to stringLength do
begin
line[destinationIndex] := ' ';
if not EOLn(input) then
begin
read(line[destinationIndex])
end
end;
{ - - processing - - - - - - - - - - - - - - - - - - - - - - - - - - - }
if lineHasVowels then
begin
destinationIndex := 1;
for sourceIndex := 1 to stringLength do
begin
if not (line[sourceIndex] in vowels) then
begin
disemvoweledLine[destinationIndex] := line[sourceIndex];
destinationIndex := destinationIndex + 1
end
end;
{ pad remaining characters in `disemvoweledLine` with spaces }
for destinationIndex := destinationIndex to stringLength do
begin
disemvoweledLine[destinationIndex] := ' '
end;
end
else
begin
disemvoweledLine := line
end;
{ - - output - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
for destinationIndex := 1 to stringLength do
begin
write(disemvoweledLine[destinationIndex])
end;
writeLn
end.</syntaxhighlight>
{{in}}
The quick brown fox jumps over the lazy dog.
{{out}}
Th qck brwn fx jmps vr th lzy dg.
----
{{works with|Extended Pascal}}
More convenient though is to use some Extended Pascal (ISO 10206) features:
<syntaxhighlight lang="pascal">program removeVowelsFromString(input, output);
const
vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'];
var
i: integer;
{ Extended Pascal: `… value ''` initializes both variables with `''`. }
line, disemvoweledLine: string(80) value '';

begin
readLn(line);
for i := 1 to length(line) do
begin
if not (line[i] in vowels) then
begin
disemvoweledLine := disemvoweledLine + line[i]
end
end;
writeLn(disemvoweledLine)
end.</syntaxhighlight>
{{in}}
The quick brown fox jumps over the lazy dog.
{{out}}
Th qck brwn fx jmps vr th lzy dg.


=={{header|Perl}}==
=={{header|Perl}}==
Inspired by the Raku entry.
Inspired by the Raku entry.
<lang perl>use strict;
<syntaxhighlight lang="perl">use strict;
use warnings;
use warnings;
use utf8;
use utf8;
Line 1,318: Line 1,704:
my @vowels;
my @vowels;
chr($_) =~ /[aæeiıoœu]/i and push @vowels, chr($_) for 0x20 .. 0x1ff;
chr($_) =~ /[aæeiıoœu]/i and push @vowels, chr($_) for 0x20 .. 0x1ff;
print NFD($_) =~ /@{[join '|', @vowels]}/ ? ' ' : $_ for split /(\X)/, $text;</lang>
print NFD($_) =~ /@{[join '|', @vowels]}/ ? ' ' : $_ for split /(\X)/, $text;</syntaxhighlight>
{{out}}
{{out}}
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
Line 1,330: Line 1,716:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="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: #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>
<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>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 1,340: Line 1,726:
</pre>
</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
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
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 1,365: Line 1,751:
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<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>
<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>
<!--</lang>-->
<!--</syntaxhighlight>-->
(output deliberately not shown due to windows console effects, but it is the same as Raku, or Julia with the alternate find/replace line.)
(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}}==
<syntaxhighlight lang="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")].</syntaxhighlight>

{{out}}
<pre>Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck
Pct prgrmmng lngg</pre>


=={{header|Prolog}}==
=={{header|Prolog}}==
Line 1,373: Line 1,770:




<syntaxhighlight lang="prolog">
<lang Prolog>
:- system:set_prolog_flag(double_quotes,chars) .
:- system:set_prolog_flag(double_quotes,chars) .


Line 1,410: Line 1,807:
lists:member(CHAR,"AEIOUaeiouüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ")
lists:member(CHAR,"AEIOUaeiouüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ")
.
.
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,432: Line 1,829:


=={{header|Python}}==
=={{header|Python}}==
===Functional===

Removing 3 particular Anglo-Saxon vowels from a string:
Removing 3 particular Anglo-Saxon vowels from a string:


{{works with|Python|3.7|}}
{{works with|Python|3.7|}}
<lang python>'''Remove a defined subset of glyphs from a string'''
<syntaxhighlight lang="python">'''Remove a defined subset of glyphs from a string'''




Line 1,445: Line 1,842:
'''
'''
def go(s):
def go(s):
return ''.join([
return ''.join(
c for c in s if c not in exclusions
c for c in s if c not in exclusions
])
)
return go
return go


Line 1,467: Line 1,864:
exceptGlyphs('eau')(txt)
exceptGlyphs('eau')(txt)
)
)



# MAIN ---
# MAIN ---
if __name__ == '__main__':
if __name__ == '__main__':
main()</lang>
main()</syntaxhighlight>
{{Out}}
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,478: Line 1,876:
diffrnt, nd to id prson with gronding
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
in on pproch to problm in lrning nothr.</pre>

===One liner===
Well, almost........
<syntaxhighlight lang="python">
txt = '''
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.'''

print(''.join(list(filter(lambda a: a not in "aeiou",txt))))
</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|Quackery}}==
=={{header|Quackery}}==
<lang Quackery>[ 0 $ "AEIOUaeiou"
<syntaxhighlight lang="quackery">[ 0 $ "AEIOUaeiou"
witheach
witheach
[ bit | ] ] constant is vowels ( --> f )
[ bit | ] ] constant is vowels ( --> f )
Line 1,491: Line 1,912:
$ '"Beautiful coquettes are quacks of love."'
$ '"Beautiful coquettes are quacks of love."'
$ ' -- Francois De La Rochefoucauld' join
$ ' -- Francois De La Rochefoucauld' join
disemvowel echo$</lang>
disemvowel echo$</syntaxhighlight>


'''Output:'''
'''Output:'''
Line 1,509: Line 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.)
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.)


<lang perl6>my @vowels = (0x20 .. 0x2fff).map: { .chr if .chr.samemark('x') ~~ m:i/<[aæeiıoœu]>/ }
<syntaxhighlight lang="raku" line>my @vowels = (0x20 .. 0x2fff).map: { .chr if .chr.samemark('x') ~~ m:i/<[aæeiıoœu]>/ }


my $text = q:to/END/;
my $text = q:to/END/;
Line 1,522: Line 1,943:
END
END


put $text.subst(/@vowels/, ' ', :g);</lang>
put $text.subst(/@vowels/, ' ', :g);</syntaxhighlight>
{{out}}
{{out}}
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
Line 1,538: Line 1,959:
=== using the TRANSLATE BIF ===
=== 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.
This REXX version uses the &nbsp; '''translate''' &nbsp; BIF which works faster for longer strings as there is no character-by-character manipulation.
<lang rexx>/*REXX program removes vowels (both lowercase and uppercase and accented) from a string.*/
<syntaxhighlight lang="rexx">/*REXX program removes vowels (both lowercase and uppercase and accented) from a string.*/
parse arg x /*obtain optional argument from the CL.*/
parse arg x /*obtain optional argument from the CL.*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
Line 1,548: Line 1,969:
y= space(translate(y, , vowels), 0) /*trans. vowels──►blanks, elide blanks.*/
y= space(translate(y, , vowels), 0) /*trans. vowels──►blanks, elide blanks.*/
y= translate(y, , q) /*trans the Q characters back to 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. */</lang>
say 'output string: ' y /*stick a fork in it, we're all done. */</syntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
{{out|output|text=&nbsp; when using the default input:}}
<pre>
<pre>
Line 1,557: Line 1,978:
=== using character eliding ===
=== using character eliding ===
This REXX version uses a character-by-character manipulation and should be easier to understand.
This REXX version uses a character-by-character manipulation and should be easier to understand.
<lang rexx>/*REXX program removes vowels (both lowercase and uppercase and accented) from a string.*/
<syntaxhighlight lang="rexx">/*REXX program removes vowels (both lowercase and uppercase and accented) from a string.*/
parse arg x /*obtain optional argument from the CL.*/
parse arg x /*obtain optional argument from the CL.*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
Line 1,571: Line 1,992:


x= substr(x, 2) /*elide the prefixed dummy character. */
x= substr(x, 2) /*elide the prefixed dummy character. */
say 'output string: ' x /*stick a fork in it, we're all done. */</lang>
say 'output string: ' x /*stick a fork in it, we're all done. */</syntaxhighlight>
{{out|output|text=&nbsp; is identical to the 1<sup>st</sup> REXX version.}} <br><br>
{{out|output|text=&nbsp; is identical to the 1<sup>st</sup> REXX version.}} <br><br>


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
load "stdlib.ring"
load "stdlib.ring"
str = "Ring Programming Language"
str = "Ring Programming Language"
Line 1,585: Line 2,006:
next
next
see "String without vowels: " + str + nl
see "String without vowels: " + str + nl
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,591: Line 2,012:
String without vowels: Rng Prgrmmng Lngg
String without vowels: Rng Prgrmmng Lngg
</pre>
</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}}==
=={{header|Ruby}}==
<lang ruby>
<syntaxhighlight lang="ruby">
p "Remove vowels from a string".delete("aeiouAEIOU") # => "Rmv vwls frm strng"
p "Remove vowels from a string".delete("aeiouAEIOU") # => "Rmv vwls frm strng"
</syntaxhighlight>
</lang>


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>
<syntaxhighlight lang="rust">
fn remove_vowels(str: String) -> String {
fn remove_vowels(str: String) -> String {
let vowels = "aeiouAEIOU";
let vowels = "aeiouAEIOU";
Line 1,618: Line 2,055:
println!("{}", remove_vowels(intro));
println!("{}", remove_vowels(intro));
}
}
</syntaxhighlight>
</lang>
Output :
Output :
<pre>
<pre>
Line 1,624: Line 2,061:
Frrs, th crb, s th nffcl msct f th Rst Prgrmmng Lngg
Frrs, th crb, s th nffcl msct f th Rst Prgrmmng Lngg
</pre>
</pre>

=={{header|sed}}==
<syntaxhighlight lang="sed">s/[AaEeIiOoUu]//g</syntaxhighlight>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
<lang smalltalk>in := 'The balloon above harsh waters of programming languages, is the mascot of Smalltalk'.
<syntaxhighlight lang="smalltalk">in := 'The balloon above harsh waters of programming languages, is the mascot of Smalltalk'.
out := in reject:[:ch | ch isVowel].
out := in reject:[:ch | ch isVowel].
in printCR.
in printCR.
out printCR.</lang>
out printCR.</syntaxhighlight>
{{out}}
{{out}}
<pre>The balloon above harsh harsh waters of programming languages, is the mascot of Smalltalk
<pre>The balloon above harsh harsh waters of programming languages, is the mascot of Smalltalk
Line 1,635: Line 2,075:


As usual, there are many alternative ways to do this:
As usual, there are many alternative ways to do this:
<lang smalltalk>out := in reject:#isVowel. " cool: symbols understand value: "
<syntaxhighlight lang="smalltalk">out := in reject:#isVowel. " cool: symbols understand value: "


out := in select:[:ch | ch isVowel not].
out := in select:[:ch | ch isVowel not].
Line 1,649: Line 2,089:
ch isVowel ifFalse:[ s nextPut:ch ]
ch isVowel ifFalse:[ s nextPut:ch ]
]]
]]
</syntaxhighlight>
</lang>


=={{header|Standard ML}}==
=={{header|Standard ML}}==
<lang sml>fun isVowel c =
<syntaxhighlight lang="sml">fun isVowel c =
CharVector.exists (fn v => c = v) "AaEeIiOoUu"
CharVector.exists (fn v => c = v) "AaEeIiOoUu"


Line 1,660: Line 2,100:
val str = "LOREM IPSUM dolor sit amet\n"
val str = "LOREM IPSUM dolor sit amet\n"
val () = print str
val () = print str
val () = print (removeVowels str)</lang>
val () = print (removeVowels str)</syntaxhighlight>
{{out}}
{{out}}
<pre>LOREM IPSUM dolor sit amet
<pre>LOREM IPSUM dolor sit amet
Line 1,666: Line 2,106:


=={{header|Swift}}==
=={{header|Swift}}==
<lang swift>func isVowel(_ char: Character) -> Bool {
<syntaxhighlight lang="swift">func isVowel(_ char: Character) -> Bool {
switch (char) {
switch (char) {
case "a", "A", "e", "E", "i", "I", "o", "O", "u", "U":
case "a", "A", "e", "E", "i", "I", "o", "O", "u", "U":
Line 1,681: Line 2,121:
let str = "The Swift Programming Language"
let str = "The Swift Programming Language"
print(str)
print(str)
print(removeVowels(string: str))</lang>
print(removeVowels(string: str))</syntaxhighlight>


{{out}}
{{out}}
Line 1,690: Line 2,130:


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
<lang vbnet>Imports System.Text
<syntaxhighlight lang="vbnet">Imports System.Text


Module Module1
Module Module1
Line 1,720: Line 2,160:
End Sub
End Sub


End Module</lang>
End Module</syntaxhighlight>
{{out}}
{{out}}
<pre>Input : Visual Basic .NET
<pre>Input : Visual Basic .NET
Output : Vsl Bsc .NT</pre>
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}}==
=={{header|Wren}}==
<lang ecmascript>var removeVowels = Fn.new { |s| s.where { |c| !"aeiouAEIOU".contains(c) }.join() }
<syntaxhighlight lang="wren">var removeVowels = Fn.new { |s| s.where { |c| !"aeiouAEIOU".contains(c) }.join() }


var s = "Wren Programming Language"
var s = "Wren Programming Language"
System.print("Input : %(s)")
System.print("Input : %(s)")
System.print("Output : %(removeVowels.call(s))")</lang>
System.print("Output : %(removeVowels.call(s))")</syntaxhighlight>


{{out}}
{{out}}
Line 1,736: Line 2,190:
Input : Wren Programming Language
Input : Wren Programming Language
Output : Wrn Prgrmmng Lngg
Output : Wrn Prgrmmng Lngg
</pre>

=={{header|XBS}}==
<syntaxhighlight lang="xbs">func RemoveVowels(x:string):string{
set Vowels:array="aeiou"::split();
set nx:string="";
for(i=0;?x-1;1){
set c = x::at(i);
if (!Vowels::has(c::lower())){
nx+=x::at(i);
}
del c;
}
del Vowels;
send nx;
}

log(RemoveVowels("Hello, world!"));</syntaxhighlight>
{{out}}
<pre>
Hll, wrld!
</pre>
</pre>


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>string 0; \make strings zero-terminated
<syntaxhighlight lang="xpl0">string 0; \make strings zero-terminated


func Disemvowel(S); \remove vowels from string
func Disemvowel(S); \remove vowels from string
Line 1,753: Line 2,228:
];
];


Text(0, Disemvowel("pack my box with FIVE DOZEN LIQUOR JUGS!"))</lang>
Text(0, Disemvowel("pack my box with FIVE DOZEN LIQUOR JUGS!"))</syntaxhighlight>


Output:
Output:
Line 1,761: Line 2,236:


=={{header|XProfan}}==
=={{header|XProfan}}==
<syntaxhighlight lang="xprofan">cls
<lang XProfan>cls
Set("RegEx",1)
Set("RegEx",1)
Var string e = "The quick brown fox jumps over the lazy dog"
Var string e = "The quick brown fox jumps over the lazy dog"
Var string a = Translate$(e,"(?i)[aeiou]","")
Var string a = Translate$(e,"(?i)[aeiou]","")
MessageBox("Input : "+e+"\nOutput: "+a,"Remove vowels",1)
MessageBox("Input : "+e+"\nOutput: "+a,"Remove vowels",1)
End</lang>
End</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>

Latest revision as of 20:00, 29 March 2024

Remove vowels from a string is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Remove vowels from a string

Other tasks related to string operations:
Metrics
Counting
Remove/replace
Anagrams/Derangements/shuffling
Find/Search/Determine
Formatting
Song lyrics/poems/Mad Libs/phrases
Tokenize
Sequences



11l

Translation of: Python
F exceptGlyphs(exclusions, s)
   R s.filter(c -> c !C @exclusions).join(‘’)

V txt = ‘
    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.’

print(exceptGlyphs(‘eau’, txt))
Output:

    Rostt Cod is  progrmming chrstomthy sit.
    Th id is to prsnt soltions to th sm
    tsk in s mny diffrnt lnggs s possibl,
    to dmonstrt how lnggs r similr nd
    diffrnt, nd to id  prson with  gronding
    in on pproch to  problm in lrning nothr.

8080 Assembly

	org	100h
	jmp	demo
	;;;	Remove the vowels from the $-terminated string at [DE]
dvwl:	push	d	; Keep output pointer on stack
vwllp:	ldax	d	; Get current byte
	inx	d	; Advance input pointer
	pop	b	; Store at output pointer
	stax	b
	cpi	'$'	; Reached the end?
	rz		; If so, stop
	push	b	; Put output pointer back on stack
	lxi	h,vwls	; Check against each vowel
	ori	32 	; Make lowercase
	mvi	b,5	; 5 vowels
vchk:	cmp	m	; Equal to current vowel?
	jz	vwllp	; Then overwrite with next character
	inx	h	; Check next vowel
	dcr	b	; Any vowels left?
	jnz	vchk
	pop	b	; Not a vowel, advance output pointer
	inx	b
	push	b
	jmp	vwllp
vwls:	db	'aeiou'	; Vowels
	;;;	Use the routine to remove vowels from a string
demo:	lxi	d,string
	call	dvwl	; Remove vowels
	lxi	d,string
	mvi	c,9	; Print using CP/M
	jmp	5
string:	db	'THE QUICK BROWN FOX jumps over the lazy dog$'
Output:
TH QCK BRWN FX jmps vr th lzy dg

Action!

BYTE FUNC IsVovel(CHAR c)
  CHAR ARRAY vovels="AEIOUaeiou"
  BYTE i

  FOR i=1 TO vovels(0)
  DO
    IF vovels(i)=c THEN
      RETURN (1)
    FI
  OD
RETURN (0)

PROC RemoveVovels(CHAR ARRAY s,res)
  BYTE i
  CHAR c

  res(0)=0
  FOR i=1 TO s(0)
  DO
    c=s(i)
    IF IsVovel(c)=0 THEN
      res(0)==+1
      res(res(0))=c
    FI
  OD
RETURN

PROC Test(CHAR ARRAY s)
  CHAR ARRAY res(256)

  RemoveVovels(s,res)
  PrintE("Input:") PrintE(s)
  PrintE("Output:") PrintE(res)
RETURN

PROC Main()
  Test("The Quick Brown Fox Jumped Over the Lazy Dog's Back")
  Test("Action! is a programming language for Atari 8-bit computer.")
RETURN
Output:

Screenshot from Atari 8-bit computer

Input:
The Quick Brown Fox Jumped Over the Lazy Dog's Back
Output:
Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck

Input:
Action! is a programming language for Atari 8-bit computer.
Output:
ctn! s  prgrmmng lngg fr tr 8-bt cmptr.

Ada

with Ada.Text_IO;           use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Main is
   subtype Vowel is Character with
        Static_Predicate => Vowel in 'A' | 'E' | 'I' | 'O' | 'U' | 'a' | 'e' |
            'i' | 'o' | 'u';

   function Remove_Vowels (S : in String) return String is
      Temp : Unbounded_String;
   begin
      for C of S loop
         if C not in Vowel then
            Append (Source => Temp, New_Item => C);
         end if;
      end loop;
      return To_String (Temp);
   end Remove_Vowels;

   S1  : String := "The Quick Brown Fox Jumped Over the Lazy Dog's Back";
   S2  : String := "DON'T SCREAM AT ME!!";
   NV1 : String := Remove_Vowels (S1);
   NV2 : String := Remove_Vowels (S2);
begin
   Put_Line (S1);
   Put_Line (NV1);
   New_Line;
   Put_Line (S2);
   Put_Line (NV2);
end Main;
Output:
The Quick Brown Fox Jumped Over the Lazy Dog's Back
Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck

DON'T SCREAM AT ME!!
DN'T SCRM T M!!

ALGOL 68

BEGIN
    # returns s with the vowels removed #
    OP DEVOWEL = ( STRING s )STRING:
       BEGIN
            [ LWB s : UPB s ]CHAR result;
            INT r pos := LWB result - 1;
            FOR s pos FROM LWB s TO UPB s DO
                IF NOT char in string( s[ s pos ], NIL, "aeiouAEIOU" ) THEN
                    # have a non-vowel - add it to the output #
                    r pos +:= 1;
                    result[ r pos ] := s[ s pos ]
                FI
            OD;
            result[ LWB s : r pos ]
       END # DEVOWEL # ;
    # tests the DEVOWEL operator #
    PROC test devowel = ( STRING s )VOID:
         print( ( "<", s, "> -> <", DEVOWEL s, ">", newline ) );
    # some test cases #
    test devowel( ""                              );
    test devowel( "aAeEiIoOuU"                    );
    test devowel( "bcdfghjklmnprstvwxyz"          );
    test devowel( "abcdefghijklmnoprstuvwxyz"     );
    test devowel( "Algol 68 Programming Language" )
END
Output:
<> -> <>
<aAeEiIoOuU> -> <>
<bcdfghjklmnprstvwxyz> -> <bcdfghjklmnprstvwxyz>
<abcdefghijklmnoprstuvwxyz> -> <bcdfghjklmnprstvwxyz>
<Algol 68 Programming Language> -> <lgl 68 Prgrmmng Lngg>

APL

devowel  ~'AaEeIiOoUu'
Output:
      devowel 'THE QUICK BROWN FOX jumps over the lazy dog'
TH QCK BRWN FX jmps vr th lzy dg

AppleScript

Functional

Removing three particular Anglo-Saxon vowels from a text.

AppleScript doesn't provide list comprehensions, and even use of regular expressions requires the study of a Foreign Function Interface to ObjC, which might be thought to defeat the goals of an entry-level scripting language.

We can at least use the universally available list monad (using a general concatMap as the bind operator here, and returning an empty list in place of any excluded glyph).

We can also improve productivity by using library functions whenever feasible.

------- REMOVE A DEFINED SUBSET OF GLYPHS FROM A TEXT ------

-- exceptGlyphs :: String -> String -> Bool
on exceptGlyphs(exclusions, s)
    script go
        on |λ|(c)
            if exclusions contains c then
                {}
            else
                {c}
            end if
        end |λ|
    end script
    
    concatMap(go, s)
end exceptGlyphs


-- Or, in terms of a general filter function:

-- exceptGlyphs2 :: String -> String -> Bool
on exceptGlyphs2(exclusions, s)
    script p
        on |λ|(c)
            exclusions does not contain c
        end |λ|
    end script
    
    filter(p, s)
end exceptGlyphs2



---------------------------- TEST --------------------------
on run
    set txt to unlines({¬
        "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."})
    
    exceptGlyphs("eau", txt)
end run



--------------------- LIBRARY FUNCTIONS --------------------

-- concatMap :: (a -> [b]) -> [a] -> [b]
on concatMap(f, xs)
    set lng to length of xs
    set acc to {}
    tell mReturn(f)
        repeat with i from 1 to lng
            set acc to acc & (|λ|(item i of xs, i, xs))
        end repeat
    end tell
    if {text, string} contains class of xs then
        acc as text
    else
        acc
    end if
end concatMap


-- filter :: (a -> Bool) -> [a] -> [a]
on filter(p, xs)
    tell mReturn(p)
        set lst to {}
        set lng to length of xs
        repeat with i from 1 to lng
            set v to item i of xs
            if |λ|(v, i, xs) then set end of lst to v
        end repeat
        if {text, string} contains class of xs then
            lst as text
        else
            lst
        end if
    end tell
end filter


-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
    -- 2nd class handler function lifted into 1st class script wrapper. 
    if script is class of f then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn


-- unlines :: [String] -> String
on unlines(xs)
    -- A single string formed by the intercalation
    -- of a list of strings with the newline character.
    set {dlm, my text item delimiters} to ¬
        {my text item delimiters, linefeed}
    set s to xs as text
    set my text item delimiters to dlm
    s
end unlines
Output:
Rostt Cod is  progrmming chrstomthy sit. 
Th id is to prsnt soltions to th sm 
tsk in s mny diffrnt lnggs s possibl, 
to dmonstrt how lnggs r similr nd 
diffrnt, nd to id  prson with  gronding 
in on pproch to  problm in lrning nothr.

Idiomatic

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.

-- 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)
    set astid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to searchText
    set textItems to mainText's text items
    set AppleScript's text item delimiters to replacementText
    set editedText to textItems as text
    set AppleScript's text item delimiters to astid
    
    return editedText
end replace

-- Demo:
set txt to "The quick brown fox jumps over the lazy dog
L'œuvre d'un élève
van Dijk
\"The Death of Åse\"
São Paulo    Győr    Malmö    Mjøsa
Jiří Bělohlávek conducts Martinů
Po co pan tak brzęczy w gąszczu?
Mahādeva"

ignoring diacriticals and case
    set devowelledText to replace(txt, {"a", "e", "i", "o", "u"}, "")
end ignoring
return devowelledText
Output:
"Th qck brwn fx jmps vr th lzy dg
L'œvr d'n lv
vn Dijk
\"Th Dth f s\"
S Pl    Gyr    Mlm    Mjøs
Jř Blhlvk cndcts Mrtn
P c pn tk brzczy w gszcz?
Mhdv"

Arturo

str: "Remove vowels from a string"

print str -- split "aeiouAEIOU"
Output:
Rmv vwls frm  strng

AutoHotkey

str := "The quick brown fox jumps over the lazy dog"
for i, v in StrSplit("aeiou")
	str := StrReplace(str, v)
MsgBox % str
Output:
Th qck brwn fx jmps vr th lzy dg

RegEx Version

str := "The quick brown fox jumps over the lazy dog"
MsgBox % str := RegExReplace(str, "i)[aeiou]")
Output:
Th qck brwn fx jmps vr th lzy dg

AWK

# syntax: GAWK -f REMOVE_VOWELS_FROM_A_STRING.AWK
BEGIN {
    IGNORECASE = 1
    arr[++n] = "The AWK Programming Language"
    arr[++n] = "The quick brown fox jumps over the lazy dog"
    for (i=1; i<=n; i++) {
      str = arr[i]
      printf("old: %s\n",str)
      gsub(/[aeiou]/,"",str)
      printf("new: %s\n\n",str)
    }
    exit(0)
}
Output:
old: The AWK Programming Language
new: Th WK Prgrmmng Lngg

old: The quick brown fox jumps over the lazy dog
new: Th qck brwn fx jmps vr th lzy dg


BASIC

Applesoft BASIC

S$ = "Remove a defined subset of glyphs from a string."
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$;
Output:
Rmv  dfnd sbst f glyphs frm  strng.

BASIC256

mensaje$ = "If Peter Piper picked a pack of pickled peppers" + " or how many pickled peppers did Peter Piper pick?"
textofinal$ = ""

for i = 1 to length(mensaje$)
	c$ = mid(mensaje$,i,1)
	begin case
		case lower(c$) = "a" or lower(c$) = "e" or lower(c$) = "i" or lower(c$) = "o" or lower(c$) = "u"
			continue for
		else
			textofinal$ += c$
	end case
next i

print textofinal$
end

PureBasic

OpenConsole()
mensaje.s = "If Peter Piper picked a pack of pickled peppers" + " or how many pickled peppers did Peter Piper pick?"
textofinal.s = ""

For i.i = 1 To Len(mensaje)
  c.s = Mid(mensaje,i,1)
  Select c
    Case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U"
      Continue
    Default
      textofinal + c
  EndSelect
Next i

PrintN(textofinal)
Input()
CloseConsole()

QBasic

Works with: QBasic version 1.1
Works with: QuickBasic version 4.5
mensaje$ = "If Peter Piper picked a pack of pickled peppers" + ", how many pickled peppers did Peter Piper pick?"
textofinal$ = ""

for i = 1 to len(mensaje$)
    c$ = mid$(mensaje$, i, 1)
    select case c$
    case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U"
        REM continue for
    case else
        textofinal$ = textofinal$ + c$
    end select
next i

print textofinal$
end

Yabasic

mensaje$ = "If Peter Piper picked a pack of pickled peppers" + " : case how many pickled peppers did Peter Piper pick?"
textofinal$ = ""

for i = 1 to len(mensaje$)
    c$ = mid$(mensaje$,i,1)
    switch c$
    case "a" : case "e" : case "i" : case "o" : case "u" : case "A" : case "E" : case "I" : case "O" : case "U"
        continue
    default
        textofinal$ = textofinal$ + c$
    end switch
next i

print textofinal$
end


BCPL

get "libhdr"

let vowel(c) = valof
$(  c := c | 32
    resultis c='a' | c='e' | c='i' | c='o' | c='u'
$)

let devowel(s) = valof
$(  let i = 1
    while i <= s%0
    $(  test vowel(s%i) 
        $(  for j=i+1 to s%0 do s%(j-1) := s%j
            s%0 := s%0 - 1
        $)
        or i := i + 1
    $)
    resultis s
$)

let start() be 
    writes(devowel("THE QUICK BROWN FOX jumps over the lazy dog.*N"))
Output:
TH QCK BRWN FX jmps vr th lzy dg.

BQN

Devowel  ¬"AaEeIiOoUu"/

C

Translation of: Go
#include <stdio.h>

void print_no_vowels(const char *s) {
    for (; *s != 0; s++) {
        switch (*s) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            break;
        default:
            putchar(*s);
            break;
        }
    }
}

void test(const char *const s) {
    printf("Input  : %s\n", s);

    printf("Output : ");
    print_no_vowels(s);
    printf("\n");
}

int main() {
    test("C Programming Language");
    return 0;
}
Output:
Input  : C Programming Language
Output : C Prgrmmng Lngg

C#

static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}
Output:
Input:  CSharp Programming Language
Output: CShrp Prgrmmng Lngg

C++

#include <algorithm>
#include <iostream>

class print_no_vowels {
private:
    const std::string &str;
public:
    print_no_vowels(const std::string &s) : str(s) {}
    friend std::ostream &operator<<(std::ostream &, print_no_vowels);
};

std::ostream &operator<<(std::ostream &os, print_no_vowels pnv) {
    auto it = pnv.str.cbegin();
    auto end = pnv.str.cend();
    std::for_each(
        it, end,
        [&os](char c) {
            switch (c) {
            case 'A':
            case 'E':
            case 'I':
            case 'O':
            case 'U':
            case 'a':
            case 'e':
            case 'i':
            case 'o':
            case 'u':
                break;
            default:
                os << c;
                break;
            }
        }
    );
    return os;
}

void test(const std::string &s) {
    std::cout << "Input  : " << s << '\n';
    std::cout << "Output : " << print_no_vowels(s) << '\n';
}

int main() {
    test("C++ Programming Language");
    return 0;
}
Output:
Input  : C++ Programming Language
Output : C++ Prgrmmng Lngg

Common 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)))

Cowgol

include "cowgol.coh";
include "strings.coh";

# Remove the vowels from a string in place
sub Devowel(str: [uint8]) is
    var out := str;
    loop
        var ch := [str];
        str := @next str;
        [out] := ch;
        if ch == 0 then
            break;
        end if;
        ch := ch | 32;
        if (ch != 'a') and 
           (ch != 'e') and 
           (ch != 'i') and
           (ch != 'o') and
           (ch != 'u') then
            out := @next out;
        end if;
    end loop;
end sub;


var str := "THE QUICK BROWN FOX jumps over the lazy dog.\n";
var buf: uint8[256];

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
Output:
TH QCK BRWN FX jmps vr th lzy dg.

D

import std.stdio;

void print_no_vowels(string s) {
    foreach (c; s) {
        switch (c) {
            case 'A', 'E', 'I', 'O', 'U':
            case 'a', 'e', 'i', 'o', 'u':
                break;
            default:
                write(c);
        }
    }
    writeln;
}

void main() {
    print_no_vowels("D Programming Language");
}
Output:
D Prgrmmng Lngg

Delphi

program Remove_vowels_from_a_string;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

function RemoveVowels(const s: string): string;
const
  VOWELS =['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'];
var
  c: char;
begin
  Result := '';
  for c in s do
  begin
    if not (c in VOWELS) then
      Result := Result + c;
  end;
end;

const
  TEST = 'The quick brown fox jumps over the lazy dog';

begin
  Writeln('Before: ', TEST);
  Writeln('After:  ', RemoveVowels(TEST));
  Readln;
end.
Output:
Before: The quick brown fox jumps over the lazy dog
After:  Th qck brwn fx jmps vr th lzy dg

EasyLang

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"

F#

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")
Output:
"Ngl Gllwy"

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
Output:
  Input string: Factor Programming Language
Without vowels: Fctr Prgrmmng Lngg

Forth

: VOWELS ( -- add len )  S" aeiouAEIOU" ;

: VALIDATE ( char addr len -- 0|n) ROT SCAN NIP ;     \ find char in string
: C+!     ( n addr )  TUCK C@ + SWAP C! ;             \ add n to byte address
: ]PAD    ( ndx -- addr ) PAD 1+  + ;                 \ index into text section
: PAD,    ( char -- ) PAD C@ ]PAD C!  1 PAD C+! ;     \ compile char into PAD, inc. count

: NOVOWELS ( addr len -- addr' len')
        0 PAD C!          \ reset byte count
        BOUNDS ( -- end start)
        ?DO
            I C@ DUP VOWELS VALIDATE
            IF   DROP    \ don't need vowels
            ELSE PAD,    \ compile char & incr. byte count
            THEN
        LOOP
        PAD COUNT ;
Output:
CREATE TEST$  S" Now is the time for all good men..." S,  ok
TEST$ COUNT NOVOWELS CR TYPE
Nw s th tm fr ll gd mn... ok

Fortran

program remove_vowels
    implicit none

    character(len=*), parameter :: string1="The quick brown fox jumps over the lazy dog."
    character(len=*), parameter :: string2="Fortran programming language"

    call print_no_vowels(string1)
    call print_no_vowels(string2)
contains
    subroutine print_no_vowels(string)
        character(len=*), intent(in)    :: string
        integer                         :: i

        do i = 1, len(string)
            select case (string(i:i))
            case('A','E','I','O','U','a','e','i','o','u')
                cycle
            case default
                write(*,'(A1)',advance="no") string(i:i)
            end select
        end do
        write(*,*) new_line('A') 
    end subroutine print_no_vowels
end program remove_vowels
Output:
Th qck brwn fx jmps vr th lzy dg. 

Frtrn prgrmmng lngg 

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

for i as uinteger = 1 to len(message)
    c=mid(message,i,1)
    select case c
    case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U":
        continue for
    case else:
        outstr += c
    end select
next i

print outstr

Free Pascal

See also Pascal

Library: strUtils
{$longStrings on}
uses
	strUtils;
var
	line: string;
	c: char;
begin
	readLn(line);
	for c in ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'] do
	begin
		line := delChars(line, c)
	end;
	writeLn(line)
end.

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 ]
Output:
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.

Fōrmulæ

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 —i.e. XML, JSON— they are intended for storage and transfer purposes more than visualization and edition.

Programs in Fōrmulæ are created/edited online in its website.

In this page you can see and run the program(s) related to this task and their results. You can also change either the programs or the parameters they are called with, for experimentation, but remember that these programs were created with the main purpose of showing a clear solution of the task, and they generally lack any kind of validation.

Solution

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
Output:
Th qck brwn fx jmps vr th lzy dg.
FtrBsc s  grt prgrmmng lngg!

Go

package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}
Output:
Input  : Go Programming Language
Output : G Prgrmmng Lngg

Haskell

Removing three specific Anglo-Saxon vowels from a text, using a general method which can apply to any specific subset of glyphs.

------ REMOVE A SPECIFIC SUBSET OF GLYPHS FROM A STRING ----
 
exceptGlyphs :: String -> String -> String
exceptGlyphs = filter . flip notElem

 
---------------------------- TEST --------------------------
txt :: String
txt =
  "Rosetta Code is a programming chrestomathy site.\n\ 
  \The idea is to present solutions to the same\n\ 
  \task in as many different languages as possible,\n\ 
  \to demonstrate how languages are similar and\n\
  \different, and to aid a person with a grounding\n\  
  \in one approach to a problem in learning another."
 
main :: IO ()
main = putStrLn $ exceptGlyphs "eau" txt
Output:
Rostt Cod is  progrmming chrstomthy sit.
Th id is to prsnt soltions to th sm
tsk in s mny diffrnt lnggs s possibl,
to dmonstrt how lnggs r similr nd
diffrnt, nd to id  prson with  gronding
in on pproch to  problm in lrning nothr.

J

devowel =: -. & 'aeiouAEIOU'

Java

You can use the String.replaceAll method, which takes a regular expression as it's first argument.

"rosettacode.org".replaceAll("(?i)[aeiou]", "");


Or

public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}

JavaScript

Removing all instances of three particular vowels from a text, using approaches that are generalisable to the removal of any specified subset of glyphs.

( Pace Jamie Zawinski, some people, when confronted with a problem, think "I know, I'll use parser combinators." )

(() => {
    'use strict'

    // Parser :: String -> Parser String
    const purgedText = exclusions =>
        fmapP(concatMap(concat))(
            sepBy(
                some(noneOf(exclusions))
            )(
                some(oneOf(exclusions))
            )
        );

    // ----------------------- TEST ------------------------
    const main = () => {
        const txt = `
            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.`

        return fst(parse(
            purgedText('eau')
        )(txt)[0]);
    };


    // ---------------- PARSER COMBINATORS -----------------

    // Parser :: String -> [(a, String)] -> Parser a
    const Parser = f =>
        // A function lifted into a Parser object.
        ({
            type: 'Parser',
            parser: f
        });


    // altP (<|>) :: Parser a -> Parser a -> Parser a
    const altP = p =>
        // p, or q if p doesn't match.
        q => Parser(s => {
            const xs = p.parser(s);
            return 0 < xs.length ? (
                xs
            ) : q.parser(s);
        });


    // apP <*> :: Parser (a -> b) -> Parser a -> Parser b
    const apP = pf =>
        // A new parser obtained by the application 
        // of a Parser-wrapped function,
        // to a Parser-wrapped value.
        p => Parser(
            s => pf.parser(s).flatMap(
                vr => fmapP(vr[0])(
                    p
                ).parser(vr[1])
            )
        );


    // bindP (>>=) :: Parser a -> 
    // (a -> Parser b) -> Parser b
    const bindP = p =>
        // A new parser obtained by the application of 
        // a function to a Parser-wrapped value.
        // The function must enrich its output, lifting it 
        // into a new Parser.
        // Allows for the nesting of parsers.
        f => Parser(
            s => p.parser(s).flatMap(
                tpl => f(tpl[0]).parser(tpl[1])
            )
        );


    // fmapP :: (a -> b) -> Parser a -> Parser b  
    const fmapP = f =>
        // A new parser derived by the structure-preserving 
        // application of f to the value in p.
        p => Parser(
            s => p.parser(s).flatMap(
                vr => Tuple(f(vr[0]))(vr[1])
            )
        );


    // liftA2P :: (a -> b -> c) -> 
    // Parser a -> Parser b -> Parser c
    const liftA2P = op =>
        // The binary function op, lifted
        // to a function over two parsers.
        p => apP(fmapP(op)(p));


    // many :: Parser a -> Parser [a]
    const many = p => {
        // Zero or more instances of p.
        // Lifts a parser for a simple type of value 
        // to a parser for a list of such values.
        const some_p = p =>
            liftA2P(
                x => xs => [x].concat(xs)
            )(p)(many(p));
        return Parser(
            s => (
                0 < s.length ? (
                    altP(some_p(p))(pureP([]))
                ) : pureP([])
            ).parser(s)
        );
    };


    // noneOf :: String -> Parser Char
    const noneOf = s =>
        // Any character not found in the
        // exclusion string.
        satisfy(c => !s.includes(c));


    // oneOf :: [Char] -> Parser Char
    const oneOf = s =>
        // One instance of any character found
        // the given string.
        satisfy(c => s.includes(c));


    // parse :: Parser a -> String -> [(a, String)]
    const parse = p =>
        // The result of parsing s with p.
        s => p.parser(s);


    // pureP :: a -> Parser a
    const pureP = x =>
        // The value x lifted, unchanged, 
        // into the Parser monad.
        Parser(s => [Tuple(x)(s)]);


    // satisfy :: (Char -> Bool) -> Parser Char
    const satisfy = test =>
        // Any character for which the 
        // given predicate returns true.
        Parser(
            s => 0 < s.length ? (
                test(s[0]) ? [
                    Tuple(s[0])(s.slice(1))
                ] : []
            ) : []
        );


    // sepBy :: Parser a -> Parser b -> Parser [a]
    const sepBy = p =>
        // Zero or more occurrences of p, as 
        // separated by (discarded) instances of sep.
        sep => altP(
            sepBy1(p)(sep)
        )(
            pureP([])
        );


    // sepBy1 :: Parser a -> Parser b -> Parser [a]
    const sepBy1 = p =>
        // One or more occurrences of p, as 
        // separated by (discarded) instances of sep.
        sep => bindP(
            p
        )(x => bindP(
            many(bindP(
                sep
            )(_ => bindP(
                p
            )(pureP))))(
            xs => pureP([x].concat(xs))));


    // some :: Parser a -> Parser [a]
    const some = p => {
        // One or more instances of p.
        // Lifts a parser for a simple type of value 
        // to a parser for a list of such values.
        const many_p = p =>
            altP(some(p))(pureP([]));
        return Parser(
            s => liftA2P(
                x => xs => [x].concat(xs)
            )(p)(many_p(p)).parser(s)
        );
    };

    // ----------------- GENERIC FUNCIONS ------------------

    // Tuple (,) :: a -> b -> (a, b)
    const Tuple = a =>
        b => ({
            type: 'Tuple',
            '0': a,
            '1': b,
            length: 2
        });


    // concat :: [[a]] -> [a]
    // concat :: [String] -> String
    const concat = xs => (
        ys => 0 < ys.length ? (
            ys.every(Array.isArray) ? (
                []
            ) : ''
        ).concat(...ys) : ys
    )(xs);


    // concatMap :: (a -> [b]) -> [a] -> [b]
    const concatMap = f =>
        // Where (a -> [b]) returns an Array, this 
        // is equivalent to .flatMap, which should be
        // used by default.
        // but if (a -> [b]) returns String rather than [Char], 
        // the monoid unit is '' in place of [], and a 
        // concatenated string is returned.
        xs => {
            const ys = list(xs).map(f);
            return 0 < ys.length ? (
                ys.some(y => 'string' !== typeof y) ? (
                    []
                ) : ''
            ).concat(...ys) : ys;
        };


    // list :: StringOrArrayLike b => b -> [a]
    const list = xs =>
        // xs itself, if it is an Array,
        // or an Array derived from xs.
        Array.isArray(xs) ? (
            xs
        ) : Array.from(xs || []);


    // map :: (a -> b) -> [a] -> [b]
    const map = f =>
        // The list obtained by applying f
        // to each element of xs.
        // (The image of xs under f).
        xs => [...xs].map(f);


    // fst :: (a, b) -> a
    const fst = tpl =>
        // First member of a pair.
        tpl[0];

    // main ---
    return main();
})();
Output:
            Rostt Cod is  progrmming chrstomthy sit. 
            Th id is to prsnt soltions to th sm 
            tsk in s mny diffrnt lnggs s possibl, 
            to dmonstrt how lnggs r similr nd 
            diffrnt, nd to id  prson with  gronding 
            in on pproch to  problm in lrning nothr.


but a filter is all we need here:

(() => {
    'use strict';

    // Parser :: String -> Parser String
    const purgedText = exclusions =>
        s => [...s]
        .filter(c => !exclusions.includes(c))
        .join('');

    // ---------------------- TEST -----------------------
    const main = () => {
        const txt = `
            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.`;

        return purgedText('eau')(txt);
    };

    // main ---
    return main();
})();
Output:
            Rostt Cod is  progrmming chrstomthy sit. 
            Th id is to prsnt soltions to th sm 
            tsk in s mny diffrnt lnggs s possibl, 
            to dmonstrt how lnggs r similr nd 
            diffrnt, nd to id  prson with  gronding 
            in on pproch to  problm in lrning nothr.

Joy

DEFINE unvowel == ["AaEeIiOoUu" in not] filter.

"Remove ALL vowels from this input!" unvowel putchars.
Output:
Rmv LL vwls frm ths npt!

jq

Works with: jq

Works with gojq, the Go implementation of jq

#!/bin/bash

vowels='AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰ'

function input {
cat<<'EOF'
In this entry, we assume that the "vowels" of the particular texts of
interest can be specified as a JSON string of letters.  Furthermore,
we take advantage of gsub's support for the "ignore case" option, "i",
so that for vowels which have both upper and lower case forms, only
one form need be included in the string.  So for example, for
unaccented English text we could use the invocation:

jq -Rr 'gsub("[aeiou]+"; ""; "i")' input.txt

The string of vowels can also be specified as an argument to jq, e.g. assuming
a bash or bash-like scripting environment:

vowels='AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰ'
jq -Rr --arg v "$vowels" 'gsub("[\($v)]+"; ""; "i")' input.txt

Norwegian, Icelandic, German, Turkish, French, Spanish, English:
Undervisningen skal være gratis, i det minste på de elementære og grunnleggende trinn.
Skal hún veitt ókeypis, að minnsta kosti barnafræðsla og undirstöðummentu.
Hochschulunterricht muß allen gleichermaßen entsprechend ihren Fähigkeiten offenstehen.
Öğrenim hiç olmazsa ilk ve temel safhalarında parasızdır. İlk öğretim mecburidir.
L'éducation doit être gratuite, au moins en ce qui concerne l'enseignement élémentaire et fondamental.
La instrucción elemental será obligatoria. La instrucción técnica y profesional habrá de ser generalizada.
Education shall be free, at least in the elementary and fundamental stages.
EOF
}

input | jq -Rr --arg v "$vowels" 'gsub("[\($v)]+"; ""; "i")'
Output:
n ths ntry, w ssm tht th "vwls" f th prtclr txts f
ntrst cn b spcfd s  JSN strng f lttrs.  Frthrmr,
w tk dvntg f gsb's spprt fr th "gnr cs" ptn, "",
s tht fr vwls whch hv bth ppr nd lwr cs frms, nly
n frm nd b ncldd n th strng.  S fr xmpl, fr
nccntd nglsh txt w cld s th nvctn:

jq -Rr 'gsb("[]+"; ""; "")' npt.txt

Th strng f vwls cn ls b spcfd s n rgmnt t jq, .g. ssmng
 bsh r bsh-lk scrptng nvrnmnt:

vwls=''
jq -Rr --rg v "$vwls" 'gsb("[\($v)]+"; ""; "")' npt.txt

Nrwgn, clndc, Grmn, Trksh, Frnch, Spnsh, nglsh:
ndrvsnngn skl vr grts,  dt mnst p d lmntr g grnnlggnd trnn.
Skl hn vtt kyps, ð mnnst kst brnfrðsl g ndrstðmmnt.
Hchschlntrrcht mß lln glchrmßn ntsprchnd hrn Fhgktn ffnsthn.
ğrnm hç lmzs lk v tml sfhlrınd prsızdır. lk ğrtm mcbrdr.
L'dctn dt tr grtt,  mns n c q cncrn l'nsgnmnt lmntr t fndmntl.
L nstrccn lmntl sr blgtr. L nstrccn tcnc y prfsnl hbr d sr gnrlzd.
dctn shll b fr, t lst n th lmntry nd fndmntl stgs.

Julia

Unicode sensitive, using the Raku version example text.

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ẙỲỴỶỸŶŸÝ"))

isvowel(ch, yisavowel=false) = haskey(yisavowel ? ALLVOWELSY : ALLVOWELS, uppercase(ch))

const testtext = """
   Norwegian, Icelandic, German, Turkish, French, Spanish, English:
   Undervisningen skal være gratis, i det minste på de elementære og grunnleggende trinn.
   Skal hún veitt ókeypis, að minnsta kosti barnafræðsla og undirstöðummentu.
   Hochschulunterricht muß allen gleichermaßen entsprechend ihren Fähigkeiten offenstehen.
   Öğrenim hiç olmazsa ilk ve temel safhalarında parasızdır. İlk öğretim mecburidir.
   L'éducation doit être gratuite, au moins en ce qui concerne l'enseignement élémentaire et fondamental.
   La instrucción elemental será obligatoria. La instrucción técnica y profesional habrá de ser generalizada.
   Education shall be free, at least in the elementary and fundamental stages."""

println("Removing vowels from:\n$testtext\n becomes:\n",
    String(filter(!isvowel, Vector{Char}(testtext))))
Output:
Removing vowels from:
Norwegian, Icelandic, German, Turkish, French, Spanish, English:
Undervisningen skal være gratis, i det minste på de elementære og grunnleggende trinn.
Skal hún veitt ókeypis, að minnsta kosti barnafræðsla og undirstöðummentu.
Hochschulunterricht muß allen gleichermaßen entsprechend ihren Fähigkeiten offenstehen.
Öğrenim hiç olmazsa ilk ve temel safhalarında parasızdır. İlk öğretim mecburidir.
L'éducation doit être gratuite, au moins en ce qui concerne l'enseignement élémentaire et fondamental.
La instrucción elemental será obligatoria. La instrucción técnica y profesional habrá de ser generalizada.
Education shall be free, at least in the elementary and fundamental stages.
 becomes:
Nrwgn, clndc, Grmn, Trksh, Frnch, Spnsh, nglsh:
ndrvsnngn skl vr grts,  dt mnst p d lmntr g grnnlggnd trnn.
Skl hn vtt kyps, ð mnnst kst brnfrðsl g ndrstðmmnt.
Hchschlntrrcht mß lln glchrmßn ntsprchnd hrn Fhgktn ffnsthn.
ğrnm hç lmzs lk v tml sfhlrnd prszdr. lk ğrtm mcbrdr.
L'dctn dt tr grtt,  mns n c q cncrn l'nsgnmnt lmntr t fndmntl.
L nstrccn lmntl sr blgtr. L nstrccn tcnc y prfsnl hbr d sr gnrlzd.
dctn shll b fr, t lst n th lmntry nd fndmntl stgs.

K

Works with: ngn/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"

Kotlin

fun removeVowels(s: String): String {
    val re = StringBuilder()
    for (c in s) {
        if (c != 'A' && c != 'a'
            && c != 'E' && c != 'e'
            && c != 'I' && c != 'i'
            && c != 'O' && c != 'o'
            && c != 'U' && c != 'u') {
            re.append(c)
        }
    }
    return re.toString()
}

fun main() {
    println(removeVowels("Kotlin Programming Language"))
}
Output:
Ktln Prgrmmng Lngg

Lambdatalk

'{S.replace [aeiouy]* by in 
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.}

-> 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.

Lua

function removeVowels (inStr)
    local outStr, letter = ""
    local vowels = "AEIUOaeiou"
    for pos = 1, #inStr do
        letter = inStr:sub(pos, pos)
        if vowels:find(letter) then
            -- This letter is a vowel
        else
            outStr = outStr .. letter
        end
    end
    return outStr
end

local testStr = "The quick brown fox jumps over the lazy dog"
print(removeVowels(testStr))
Output:
Th qck brwn fx jmps vr th lzy dg



Mathematica/Wolfram Language

StringReplace["The Quick Brown Fox Jumped Over the Lazy Dog's Back", (Alternatives @@ Characters["aeiou"]) -> ""]
Output:
Th Qck Brwn Fx Jmpd Ovr th Lzy Dg's Bck

MATLAB / Octave

function [result] = remove_vowels(text)
% http://rosettacode.org/wiki/Remove_vowels_from_a_string

flag=zeros(size(text));
for c='AEIOUaeiou'
        flag=flag|(text==c);
end
result=text(~flag); 
end

remove_vowels('The AWK Programming Language')
remove_vowels('The quick brown fox jumps over the lazy dog')

%!test
%! assert(remove_vowels('The AWK Programming Language'),'Th WK Prgrmmng Lngg')
%!test
%! assert(remove_vowels('The quick brown fox jumps over the lazy dog'),'Th qck brwn fx jmps vr th lzy dg')
Output:
ans = Th WK Prgrmmng Lngg
ans = Th qck brwn fx jmps vr th lzy dg

Nim

import strutils, sugar

const Vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}

proc removeVowels(str: var string; vowels: set[char]) =
  ## Remove vowels from string "str".
  var start = 0
  while true:
    let pos = str.find(vowels, start)
    if pos < 0: break
    str.delete(pos, pos)
    start = pos

const TestString = "The quick brown fox jumps over the lazy dog"
echo TestString
echo TestString.dup(removeVowels(Vowels))
Output:
The quick brown fox jumps over the lazy dog
Th qck brwn fx jmps vr th lzy dg

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

Pascal

See also Delphi or Free Pascal
This program works with any ISO 7185 compliant compiler.

program removeVowelsFromString(input, output);

const
	stringLength = 80;

type
	stringIndex = 1..stringLength;
	string = array[stringIndex] of char;

var
	sourceIndex, destinationIndex: stringIndex;
	line, disemvoweledLine: string;
	vowels: set of char;

function lineHasVowels: Boolean;
var
	sourceIndex: stringIndex;
	vowelIndices: set of stringIndex;
begin
	vowelIndices := [];
	
	for sourceIndex := 1 to stringLength do
	begin
		if line[sourceIndex] in vowels then
		begin
			vowelIndices := vowelIndices + [sourceIndex]
		end
	end;
	
	lineHasVowels := vowelIndices <> []
end;

begin
	vowels := ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'];
	
	{ - - input - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
	for destinationIndex := 1 to stringLength do
	begin
		line[destinationIndex] := ' ';
		if not EOLn(input) then
		begin
			read(line[destinationIndex])
		end
	end;
	
	{ - - processing  - - - - - - - - - - - - - - - - - - - - - - - - - - - }
	if lineHasVowels then
	begin
		destinationIndex := 1;
		for sourceIndex := 1 to stringLength do
		begin
			if not (line[sourceIndex] in vowels) then
			begin
				disemvoweledLine[destinationIndex] := line[sourceIndex];
				destinationIndex := destinationIndex + 1
			end
		end;
		{ pad remaining characters in `disemvoweledLine` with spaces }
		for destinationIndex := destinationIndex to stringLength do
		begin
			disemvoweledLine[destinationIndex] := ' '
		end;
	end
	else
	begin
		disemvoweledLine := line
	end;
	
	{ - - output  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
	for destinationIndex := 1 to stringLength do
	begin
		write(disemvoweledLine[destinationIndex])
	end;
	writeLn
end.
Input:
The quick brown fox jumps over the lazy dog.
Output:
Th qck brwn fx jmps vr th lzy dg.                                               

Works with: Extended Pascal

More convenient though is to use some Extended Pascal (ISO 10206) features:

program removeVowelsFromString(input, output);
const
	vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'];
var
	i: integer;
	{ Extended Pascal: `… value ''` initializes both variables with `''`. }
	line, disemvoweledLine: string(80) value '';

begin
	readLn(line);
	
	for i := 1 to length(line) do
	begin
		if not (line[i] in vowels) then
		begin
			disemvoweledLine := disemvoweledLine + line[i]
		end
	end;
	
	writeLn(disemvoweledLine)
end.
Input:
The quick brown fox jumps over the lazy dog.
Output:
Th qck brwn fx jmps vr th lzy dg.

Perl

Inspired by the Raku entry.

use strict;
use warnings;
use utf8;
binmode STDOUT, ":utf8";
use Unicode::Normalize;

my $text = <<~'END';
    Norwegian, Icelandic, German, Turkish, French, Spanish, English:
    Undervisningen skal være gratis, i det minste  de elementære og grunnleggende trinn.
    Skal hún veitt ókeypis,  minnsta kosti barnafræðsla og undirstöðummentu.
    Hochschulunterricht muß allen gleichermaßen entsprechend ihren Fähigkeiten offenstehen.
    Öğrenim hiç olmazsa ilk ve temel safhalarında parasızdır. İlk öğretim mecburidir.
    L'éducation doit être gratuite, au moins en ce qui concerne l'enseignement élémentaire et fondamental.
    La instrucción elemental será obligatoria. La instrucción técnica y profesional habrá de ser generalizada.
    Education shall be free, at least in the elementary and fundamental stages.
    END

my @vowels;
chr($_) =~ /[aæeiıoœu]/i and push @vowels, chr($_) for 0x20 .. 0x1ff;
print NFD($_) =~ /@{[join '|', @vowels]}/ ? ' ' : $_ for split /(\X)/, $text;
Output:
N rw g  n,  c l nd c, G rm n, T rk sh, Fr nch, Sp n sh,  ngl sh:
 nd rv sn ng n sk l v r  gr t s,   d t m nst  p  d   l m nt r   g gr nnl gg nd  tr nn.
Sk l h n v  tt  k yp s,  ð m nnst  k st  b rn fr ðsl   g  nd rst ð mm nt .
H chsch l nt rr cht m ß  ll n gl  ch rm ß n  ntspr ch nd  hr n F h gk  t n  ff nst h n.
 ğr n m h ç  lm zs   lk v  t m l s fh l r nd  p r s zd r.  lk  ğr t m m cb r d r.
L' d c t  n d  t  tr  gr t  t ,    m  ns  n c  q   c nc rn  l' ns  gn m nt  l m nt  r   t f nd m nt l.
L   nstr cc  n  l m nt l s r   bl g t r  . L   nstr cc  n t cn c  y pr f s  n l h br  d  s r g n r l z d .
 d c t  n sh ll b  fr  ,  t l  st  n th   l m nt ry  nd f nd m nt l st g s.

Phix

constant s = "Phix Programming Language"
printf(1,"Input  : %s\nOutput : %s\n",{s,filter(s,"out","aeiouAEIUO")})
Output:
Input  : Phix Programming Language
Output : Phx Prgrmmng Lngg

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

with javascript_semantics

constant vowels = utf8_to_utf32("AEIOUIÖaeiouæáåäéêióöú"),
s = """
Norwegian, Icelandic, German, Turkish, French, Spanish, English:
Undervisningen skal være gratis, i det minste på de elementære og grunnleggende trinn.
Skal hún veitt ókeypis, að minnsta kosti barnafræðsla og undirstöðummentu.
Hochschulunterricht muß allen gleichermaßen entsprechend ihren Fähigkeiten offenstehen.
Ögrenim hiç olmazsa ilk ve temel safhalarinda parasizdir. Ilk ögretim mecburidir.
L'éducation doit être gratuite, au moins en ce qui concerne l'enseignement élémentaire et fondamental.
La instrucción elemental será obligatoria. La instrucción técnica y profesional habrá de ser generalizada.
Education shall be free, at least in the elementary and fundamental stages.
"""
 
function remove_vowels(sequence s)
    s = utf8_to_utf32(s)
    for i=length(s) to 1 by -1 do
        if find(s[i],vowels) then s[i] = ' ' end if
--      if find(s[i],vowels) then s[i..i] = "" end if
    end for
    s = utf32_to_utf8(s)
    return s
end function
printf(1,"%s\n",remove_vowels(s))

(output deliberately not shown due to windows console effects, but it is the same as Raku, or Julia with the alternate find/replace line.)

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")].
Output:
Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck
Pct prgrmmng lngg

Prolog

Works with: SWI-Prolog version 7


:- system:set_prolog_flag(double_quotes,chars) .

:- [library(lists)] .

%! remove_vowels(INPUTz0,OUTPUTz0)
%
% `OUTPUTz0` is `INPUTz0` but without any vowels .

remove_vowels(INPUTz0,OUTPUTz0)
:-
prolog:phrase(remove_vowels(INPUTz0),OUTPUTz0)
.

remove_vowels([])
-->
[]
.

remove_vowels([INPUT0|INPUTz0])
-->
{ vowel(INPUT0) } ,
! ,
remove_vowels(INPUTz0)
.

remove_vowels([INPUT0|INPUTz0])
-->
! ,
[INPUT0] ,
remove_vowels(INPUTz0)
.

vowel(CHAR)
:-
lists:member(CHAR,"AEIOUaeiouüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ")
.
Output:
/*
?- remove_vowels("abcdef",Ys).
Ys = [b, c, d, f].

?- remove_vowels("",Ys).
Ys = [].

?- remove_vowels("aeiou",Ys).
Ys = [].

?- remove_vowels("bcdfg",Ys).
Ys = [b, c, d, f, g].

?- 
*/

Python

Functional

Removing 3 particular Anglo-Saxon vowels from a string:

Works with: Python version 3.7
'''Remove a defined subset of glyphs from a string'''


# exceptGlyphs :: String -> String -> String
def exceptGlyphs(exclusions):
    '''A string from which all instances of a
       given set of glyphs have been removed.
    '''
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go


# -------------------------- TEST --------------------------
# main :: IO ()
def main():
    '''Test'''

    txt = '''
        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.'''

    print(
        exceptGlyphs('eau')(txt)
    )


# MAIN ---
if __name__ == '__main__':
    main()
Output:
        Rostt Cod is  progrmming chrstomthy sit. 
        Th id is to prsnt soltions to th sm 
        tsk in s mny diffrnt lnggs s possibl, 
        to dmonstrt how lnggs r similr nd 
        diffrnt, nd to id  prson with  gronding 
        in on pproch to  problm in lrning nothr.

One liner

Well, almost........

txt = '''
        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.'''

print(''.join(list(filter(lambda a: a not in "aeiou",txt))))
Output:
        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.

Quackery

[ 0 $ "AEIOUaeiou"
  witheach
    [ bit | ] ] constant     is vowels     (   --> f )

[ $ "" swap
  witheach
    [ dup bit vowels & 0 =
      iff join else drop ] ] is disemvowel ( $ --> $ )

$ '"Beautiful coquettes are quacks of love."'
$ ' -- Francois De La Rochefoucauld' join
disemvowel echo$

Output:

"Btfl cqtts r qcks f lv." -- Frncs D L Rchfcld

Raku

Works with: Rakudo version 2020.07

Not going to bother with 'y', it's too touchy feely (How many vowels are in the word my? why? any?) and subject to interpretation.

Otherwise, this should work for most Latinate languages.

Apropos of nothing; reminds me of one of my favorite Between the Lions performances: Sloppy Pop - Sometimes Y

Spec is 'Remove vowels from a string'; nothing about what they should be replaced with. I chose to replace them with spaces.

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.)

my @vowels = (0x20 .. 0x2fff).map: { .chr if .chr.samemark('x') ~~ m:i/<[aæeiıoœu]>/ }

my $text = q:to/END/;
   Norwegian, Icelandic, German, Turkish, French, Spanish, English:
   Undervisningen skal være gratis, i det minste på de elementære og grunnleggende trinn.
   Skal hún veitt ókeypis, að minnsta kosti barnafræðsla og undirstöðummentu.
   Hochschulunterricht muß allen gleichermaßen entsprechend ihren Fähigkeiten offenstehen.
   Öğrenim hiç olmazsa ilk ve temel safhalarında parasızdır. İlk öğretim mecburidir.
   L'éducation doit être gratuite, au moins en ce qui concerne l'enseignement élémentaire et fondamental.
   La instrucción elemental será obligatoria. La instrucción técnica y profesional habrá de ser generalizada.
   Education shall be free, at least in the elementary and fundamental stages.
   END

put $text.subst(/@vowels/, ' ', :g);
Output:
N rw g  n,  c l nd c, G rm n, T rk sh, Fr nch, Sp n sh,  ngl sh:
 nd rv sn ng n sk l v r  gr t s,   d t m nst  p  d   l m nt r   g gr nnl gg nd  tr nn.
Sk l h n v  tt  k yp s,  ð m nnst  k st  b rn fr ðsl   g  nd rst ð mm nt .
H chsch l nt rr cht m ß  ll n gl  ch rm ß n  ntspr ch nd  hr n F h gk  t n  ff nst h n.
 ğr n m h ç  lm zs   lk v  t m l s fh l r nd  p r s zd r.  lk  ğr t m m cb r d r.
L' d c t  n d  t  tr  gr t  t ,    m  ns  n c  q   c nc rn  l' ns  gn m nt  l m nt  r   t f nd m nt l.
L   nstr cc  n  l m nt l s r   bl g t r  . L   nstr cc  n t cn c  y pr f s  n l h br  d  s r g n r l z d .
 d c t  n sh ll b  fr  ,  t l  st  n th   l m nt ry  nd f nd m nt l st g s.

REXX

These two REXX versions remove the Latin (Roman) vowels and all those accented and Greek vowels that are supported in the   437   code page.

using the TRANSLATE BIF

This REXX version uses the   translate   BIF which works faster for longer strings as there is no character-by-character manipulation.

/*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*/
say ' input string: '    x
vowels= 'AEIOUaeiou' || "üéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ"  /*Latin + accented + Greek*/
$= translate( xrange(), ., ' ')                  /*define a string of almost all chars. */
q= substr($, verify($, x), 1)                    /*find a character NOT in the X string.*/
y= translate(x, q, " ")                          /*trans. blanks in the string (for now)*/
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. */
output   when using the default input:
 input string:  REXX Programming Language
output string:  RXX Prgrmmng Lngg

using character eliding

This REXX version uses a character-by-character manipulation and should be easier to understand.

/*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*/
say ' input string: '    x
vowels= 'AEIOUaeiou' || "üéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ"  /*Latin + accented + Greek*/
x= . || x                                        /*prefix string with a dummy character.*/

     do j=length(x)-1  by -1  for  length(x)-1   /*process the string from the back─end.*/
     _= pos( substr(x, j, 1), vowels)            /*is this particular character a vowel?*/
     if _==0  then iterate                       /*if zero  (not a vowel), then skip it.*/
     x= left(x, j - 1)  ||  substr(x, j + 1)     /*elide the vowel just detected from X.*/
     end   /*j*/

x= substr(x, 2)                                  /*elide the prefixed dummy character.  */
say 'output string: '    x                       /*stick a fork in it,  we're all done. */
output   is identical to the 1st REXX version.



Ring

load "stdlib.ring"
str = "Ring Programming Language"
see "Input : " + str + nl
for n = 1 to len(str)
    if isVowel(str[n])
       str = substr(str,str[n],"")
    ok
next
see "String without vowels: " + str + nl
Output:
Input : Ring Programming Language
String without vowels: Rng Prgrmmng Lngg

RPL

≪ "AEIOUaeiou" → string vowels
  ≪ "" 1 string SIZE FOR j
       string j DUP SUB
       IF vowels OVER POS THEN DROP ELSE + END 
    NEXT
≫ ≫ 'NOVWL' STO
Input:
"This is a difficult sentence to pronounce" NOVWL
Output:
1: "Ths s  dffclt sntnc t prnnc"

Ruby

p "Remove vowels from a string".delete("aeiouAEIOU") # => "Rmv vwls frm  strng"

Rust

fn remove_vowels(str: String) -> String {
    let vowels = "aeiouAEIOU";
    let mut devowelled_string = String::from("");

    for i in str.chars() {
        if vowels.contains(i) {
            continue;
        } else {
            devowelled_string.push(i);
        }
    }
    return devowelled_string;
}

fn main() {
    let intro =
        String::from("Ferris, the crab, is the unofficial mascot of the Rust Programming Language");
    println!("{}", intro);
    println!("{}", remove_vowels(intro));
}

Output :

Ferris, the crab, is the unofficial mascot of the Rust Programming Language
Frrs, th crb, s th nffcl msct f th Rst Prgrmmng Lngg

sed

s/[AaEeIiOoUu]//g

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.
Output:
The balloon above harsh harsh waters of programming languages, is the mascot of Smalltalk
Th blln bv hrsh wtrs f prgrmmng lnggs, s th msct f Smlltlk

As usual, there are many alternative ways to do this:

out := in reject:#isVowel.   " cool: symbols understand value: "

out := in select:[:ch | ch isVowel not].

out := in reject:[:ch | 'aeiou' includes:ch asLowercase ].

out := in reject:[:ch | #( $a $e $i $o $u ) includes:ch asLowercase ].

out := in reject:[:ch | 'AaEeIiOoUu' includes:ch ].

out := String streamContents:[:s |
    in do:[:ch |
        ch isVowel ifFalse:[ s nextPut:ch ]
    ]]

Standard ML

fun isVowel c =
  CharVector.exists (fn v => c = v) "AaEeIiOoUu"

val removeVowels =
  String.translate (fn c => if isVowel c then "" else str c)

val str = "LOREM IPSUM dolor sit amet\n"
val () = print str
val () = print (removeVowels str)
Output:
LOREM IPSUM dolor sit amet
LRM PSM dlr st mt

Swift

func isVowel(_ char: Character) -> Bool {
    switch (char) {
    case "a", "A", "e", "E", "i", "I", "o", "O", "u", "U":
        return true
    default:
        return false
    }
}

func removeVowels(string: String) -> String {
    return string.filter{!isVowel($0)}
}

let str = "The Swift Programming Language"
print(str)
print(removeVowels(string: str))
Output:
The Swift Programming Language
Th Swft Prgrmmng Lngg

Visual Basic .NET

Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Output:
Input  : Visual Basic .NET
Output : Vsl Bsc .NT

V (Vlang)

Translation of: AutoHotkey
fn main() {
    mut str := 'The quick brown fox jumps over the lazy dog'
    for val in 'aeiou'.split('') {str = str.replace(val,'')}
    println(str)
}
Output:
Th qck brwn fx jmps vr th lzy dg

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))")
Output:
Input  : Wren Programming Language
Output : Wrn Prgrmmng Lngg

XBS

func RemoveVowels(x:string):string{
	set Vowels:array="aeiou"::split();
	set nx:string="";
	for(i=0;?x-1;1){
		set c = x::at(i);
		if (!Vowels::has(c::lower())){
			nx+=x::at(i);
		}
		del c;
	}
	del Vowels;
	send nx;
}

log(RemoveVowels("Hello, world!"));
Output:
Hll, wrld!

XPL0

string 0;                       \make strings zero-terminated

func Disemvowel(S);             \remove vowels from string
char S;
int  I, O;
[O:= 0;
for I:= 0 to -1>>1 do           \for many times...
    [case S(I) ! $20 of         \shift to lowercase
      ^a,^e,^i,^o,^u: []        \do nothing
    other [S(O):= S(I);  O:= O+1]; \otherwise copy char
    if S(I)=0 then return S;
    ];
];

Text(0, Disemvowel("pack my box with FIVE DOZEN LIQUOR JUGS!"))

Output:

pck my bx wth FV DZN LQR JGS!

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
Output:
Input : The quick brown fox jumps over the lazy dog
Output: Th qck brwn fx jmps vr th lzy dg