Remove vowels from a string: Difference between revisions
m
→{{header|EasyLang}}
(Added solution for Action!) |
|||
(28 intermediate revisions by 20 users not shown) | |||
Line 9:
{{trans|Python}}
<
R s.filter(c -> c !C @exclusions).join(‘’)
Line 20:
in one approach to a problem in learning another.’
print(exceptGlyphs(‘eau’, txt))</
{{out}}
Line 35:
=={{header|8080 Assembly}}==
<
jmp demo
;;; Remove the vowels from the $-terminated string at [DE]
Line 65:
mvi c,9 ; Print using CP/M
jmp 5
string: db 'THE QUICK BROWN FOX jumps over the lazy dog$'</
{{out}}
Line 72:
=={{header|Action!}}==
<
CHAR ARRAY vovels="AEIOUaeiou"
BYTE i
Line 110:
Test("The Quick Brown Fox Jumped Over the Lazy Dog's Back")
Test("Action! is a programming language for Atari 8-bit computer.")
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Remove_vowels_from_a_string.png Screenshot from Atari 8-bit computer]
Line 126:
=={{header|Ada}}==
<
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
Line 156:
Put_Line (NV2);
end Main;
</syntaxhighlight>
{{output}}
<pre>
Line 167:
=={{header|ALGOL 68}}==
<
# returns s with the vowels removed #
OP DEVOWEL = ( STRING s )STRING:
Line 191:
test devowel( "abcdefghijklmnoprstuvwxyz" );
test devowel( "Algol 68 Programming Language" )
END</
{{out}}
<pre>
Line 202:
=={{header|APL}}==
<syntaxhighlight lang
{{out}}
<pre> devowel 'THE QUICK BROWN FOX jumps over the lazy dog'
Line 217:
We can also improve productivity by using library functions whenever feasible.
<
-- exceptGlyphs :: String -> String -> Bool
Line 324:
set my text item delimiters to dlm
s
end unlines</
{{Out}}
<pre>Rostt Cod is progrmming chrstomthy sit.
Line 337:
As has been noted on the Discussion page, this is necessarily a parochial task which depends on the natural language involved being written with vowels and consonants and on what constitutes a vowel in its orthography. w and y are vowels in Welsh, but consonants in English, although y is often used as a vowel in English too, as it is in other languages. The code below demonstrates how AppleScript might remove the five English vowels and their diacritical forms from a Latinate text. AppleScript can be made to "ignore" diacriticals and case in string comparisons, but not to ignore ligatures or other variations which aren't strictly speaking diacriticals, such as ø. These would need to be included in the vowel list explicitly.
<
-- searchText can be either a single string or a list of strings to be replaced with replacementText.
on replace(mainText, searchText, replacementText)
Line 363:
set devowelledText to replace(txt, {"a", "e", "i", "o", "u"}, "")
end ignoring
return devowelledText</
{{output}}
<
L'œvr d'n lv
vn Dijk
Line 373:
Jř Blhlvk cndcts Mrtn
P c pn tk brzczy w gszcz?
Mhdv"</
=={{header|Arturo}}==
<
print str -- split "aeiouAEIOU"</
{{out}}
Line 386:
=={{header|AutoHotkey}}==
<
for i, v in StrSplit("aeiou")
str := StrReplace(str, v)
MsgBox % str</
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
===RegEx Version===
<
MsgBox % str := RegExReplace(str, "i)[aeiou]")</
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f REMOVE_VOWELS_FROM_A_STRING.AWK
BEGIN {
Line 413:
exit(0)
}
</syntaxhighlight>
{{out}}
<pre>
Line 422:
new: Th qck brwn fx jmps vr th lzy dg
</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}}==
<
let vowel(c) = valof
Line 443 ⟶ 526:
let start() be
writes(devowel("THE QUICK BROWN FOX jumps over the lazy dog.*N"))</
{{out}}
<pre>TH QCK BRWN FX jmps vr th lzy dg.</pre>
=={{header|BQN}}==
<syntaxhighlight lang="bqn">Devowel ← ¬∘∊⟜"AaEeIiOoUu"⊸/</syntaxhighlight>
=={{header|C}}==
{{trans|Go}}
<
void print_no_vowels(const char *s) {
Line 483 ⟶ 569:
test("C Programming Language");
return 0;
}</
{{out}}
<pre>Input : C Programming Language
Line 489 ⟶ 575:
=={{header|C#}}==
<
{
var stripped = from c in value.ToCharArray()
Line 508 ⟶ 594:
test("CSharp Programming Language");
}
</syntaxhighlight>
{{out}}
<pre>Input: CSharp Programming Language
Line 514 ⟶ 600:
=={{header|C++}}==
<
#include <iostream>
Line 560 ⟶ 646:
test("C++ Programming Language");
return 0;
}</
{{out}}
<pre>Input : C++ Programming Language
Line 567 ⟶ 653:
=={{header|Common Lisp}}==
<
(and (characterp c) (characterp (find c vowels :test #'char-equal))))
(defun remove-vowels (s)
(and (stringp s) (remove-if #'vowel-p s)))</
=={{header|Cowgol}}==
<
include "strings.coh";
Line 604 ⟶ 690:
CopyString(str, &buf[0]); # make a copy of the string into writeable memory
Devowel(&buf[0]); # remove the vowels
print(&buf[0]); # print the result </
{{out}}
Line 611 ⟶ 697:
=={{header|D}}==
<
void print_no_vowels(string s) {
Line 628 ⟶ 714:
void main() {
print_no_vowels("D Programming Language");
}</
{{out}}
<pre>D Prgrmmng Lngg</pre>
Line 634 ⟶ 720:
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
<syntaxhighlight lang="delphi">
program Remove_vowels_from_a_string;
Line 667 ⟶ 753:
end.
</syntaxhighlight>
{{out}}
Line 674 ⟶ 760:
After: Th qck brwn fx jmps vr th lzy dg
</pre>
=={{header|EasyLang}}==
<syntaxhighlight>
func$ rmv s$ .
for c$ in strchars s$
if strpos "AEIOUaeiou" c$ <> 0
c$ = ""
.
r$ &= c$
.
return r$
.
print rmv "The Quick Brown Fox Jumped Over the Lazy Dog's Back"
</syntaxhighlight>
=={{header|F_Sharp|F#}}==
<
let stripVowels n=let g=set['a';'e';'i';'o';'u';'A';'E';'I';'O';'U'] in n|>Seq.filter(fun n->not(g.Contains n))|>Array.ofSeq|>System.String
printfn "%s" (stripVowels "Nigel Galloway")
</syntaxhighlight>
{{out}}
<pre>
Line 686 ⟶ 786:
=={{header|Factor}}==
<
: without-vowels ( str -- new-str ) "aeiouAEIOU" without ;
"Factor Programming Language" dup without-vowels
" Input string: %s\nWithout vowels: %s\n" printf</
{{out}}
<pre>
Input string: Factor Programming Language
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>
=={{header|Fortran}}==
<
program remove_vowels
implicit none
Line 724 ⟶ 849:
end subroutine print_no_vowels
end program remove_vowels
</syntaxhighlight>
{{out}}
<pre>
Line 734 ⟶ 859:
=={{header|FreeBASIC}}==
<
", how many pickled peppers did Peter Piper pick?"
dim as string outstr = "", c
Line 748 ⟶ 873:
next i
print outstr</
=={{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æ}}==
{{FormulaeEntry|page=https://formulae.org/?script=examples/Remove_vowels_from_a_string}}
'''Solution'''
[[File:Fōrmulæ - Remove vowels from a string 01.png]]
[[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}}==
<
import (
Line 781 ⟶ 961:
fmt.Println("Input :", s)
fmt.Println("Output :", removeVowels(s))
}</
{{out}}
Line 793 ⟶ 973:
Removing three specific Anglo-Saxon vowels from a text, using a general method which can apply to any specific subset of glyphs.
<
exceptGlyphs :: String -> String -> String
Line 810 ⟶ 990:
main :: IO ()
main = putStrLn $ exceptGlyphs "eau" txt</
{{Out}}
Line 823 ⟶ 999:
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
=={{header|J}}==
<syntaxhighlight lang="j">devowel =: -. & 'aeiouAEIOU'</syntaxhighlight>
=={{header|Java}}==
You can use the ''String.replaceAll'' method, which takes a regular expression as it's first argument.
<syntaxhighlight lang="java">
"rosettacode.org".replaceAll("(?i)[aeiou]", "");
</syntaxhighlight>
<br />
Or
<syntaxhighlight lang="java">public static String removeVowelse(String str){
String re = "";
char c;
Line 834 ⟶ 1,019:
}
return re;
}</
=={{header|JavaScript}}==
Line 842 ⟶ 1,027:
( ''Pace'' Jamie Zawinski, some people, when confronted with a problem, think "I know, I'll use '''parser combinators'''." )
<
'use strict'
Line 1,105 ⟶ 1,290:
// main ---
return main();
})();</
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,117 ⟶ 1,302:
but a filter is all we need here:
<
'use strict';
Line 1,141 ⟶ 1,326:
// main ---
return main();
})();</
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,149 ⟶ 1,334:
diffrnt, nd to id prson with gronding
in on pproch to problm in lrning nothr.</pre>
=={{header|Joy}}==
<syntaxhighlight lang="joy">DEFINE unvowel == ["AaEeIiOoUu" in not] filter.
"Remove ALL vowels from this input!" unvowel putchars.</syntaxhighlight>
{{out}}
<pre>Rmv LL vwls frm ths npt!</pre>
=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang="sh">
#!/bin/bash
Line 1,187 ⟶ 1,379:
input | jq -Rr --arg v "$vowels" 'gsub("[\($v)]+"; ""; "i")'
</syntaxhighlight>
{{out}}
<pre>
Line 1,217 ⟶ 1,409:
=={{header|Julia}}==
Unicode sensitive, using the Raku version example text.
<
const ALLVOWELSY = Dict(ch => 1 for ch in Vector{Char}("AÀÁÂÃÄÅĀĂĄǺȀȂẠẢẤẦẨẪẬẮẰẲẴẶḀÆǼEȄȆḔḖḘḚḜẸẺẼẾỀỂỄỆĒĔĖĘĚÈÉÊËIȈȊḬḮỈỊĨĪĬĮİÌÍÎÏIJOŒØǾȌȎṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢŌÒÓŎŐÔÕÖUŨŪŬŮŰŲÙÚÛÜȔȖṲṴṶṸṺỤỦỨỪỬỮỰYẙỲỴỶỸŶŸÝ"))
Line 1,234 ⟶ 1,426:
println("Removing vowels from:\n$testtext\n becomes:\n",
String(filter(!isvowel, Vector{Char}(testtext))))
</
<pre>
Removing vowels from:
Line 1,255 ⟶ 1,447:
dctn shll b fr, t lst n th lmntry nd fndmntl stgs.
</pre>
=={{header|K}}==
{{works with|ngn/k}}
<syntaxhighlight lang=K>novowel: {x^"aeiouAEIOU"}
novowel"The Quick Brown Fox Jumped Over the Lazy Dog's Back"
"Th Qck Brwn Fx Jmpd vr th Lzy Dg's Bck"
</syntaxhighlight>
=={{header|Kotlin}}==
<
val re = StringBuilder()
for (c in s) {
Line 1,273 ⟶ 1,473:
fun main() {
println(removeVowels("Kotlin Programming Language"))
}</
{{out}}
<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}}==
<
local outStr, letter = ""
local vowels = "AEIUOaeiou"
Line 1,293 ⟶ 1,506:
local testStr = "The quick brown fox jumps over the lazy dog"
print(removeVowels(testStr))</
{{out}}
<pre>Th qck brwn fx jmps vr th lzy dg</pre>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
{{out}}
<pre>Th Qck Brwn Fx Jmpd Ovr th Lzy Dg's Bck</pre>
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab">
function [result] = remove_vowels(text)
% http://rosettacode.org/wiki/Remove_vowels_from_a_string
Line 1,321 ⟶ 1,537:
%!test
%! assert(remove_vowels('The quick brown fox jumps over the lazy dog'),'Th qck brwn fx jmps vr th lzy dg')
</syntaxhighlight>
{{out}}
Line 1,330 ⟶ 1,546:
=={{header|Nim}}==
<
const Vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
Line 1,345 ⟶ 1,561:
const TestString = "The quick brown fox jumps over the lazy dog"
echo TestString
echo TestString.dup(removeVowels(Vowels))</
{{out}}
<pre>The quick brown fox jumps over the lazy dog
Th qck brwn fx jmps vr th lzy dg</pre>
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let remove_vowels s : string =
let not_vowel = Fun.negate (String.contains "AaEeIiOoUu") in
String.to_seq s |> Seq.filter not_vowel |> String.of_seq</syntaxhighlight>
=={{header|Pascal}}==
''See also [[#Delphi|Delphi]] or [[#Free Pascal|Free Pascal]]''<br/>
This program works with any ISO 7185 compliant compiler.
<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}}==
Inspired by the Raku entry.
<
use warnings;
use utf8;
Line 1,372 ⟶ 1,704:
my @vowels;
chr($_) =~ /[aæeiıoœu]/i and push @vowels, chr($_) for 0x20 .. 0x1ff;
print NFD($_) =~ /@{[join '|', @vowels]}/ ? ' ' : $_ for split /(\X)/, $text;</
{{out}}
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
Line 1,384 ⟶ 1,716:
=={{header|Phix}}==
<!--<
<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>
<!--</
{{out}}
<pre>
Line 1,394 ⟶ 1,726:
</pre>
If you want something a bit more like Julia/Raku, the following should work, but you have to provide your own vowel-set, or nick/merge from Julia/REXX
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 1,419 ⟶ 1,751:
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">remove_vowels</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">))</span>
<!--</
(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}}==
Line 1,427 ⟶ 1,770:
<syntaxhighlight lang="prolog">
:- system:set_prolog_flag(double_quotes,chars) .
Line 1,464 ⟶ 1,807:
lists:member(CHAR,"AEIOUaeiouüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúªºαΩ")
.
</syntaxhighlight>
{{out}}
Line 1,490 ⟶ 1,833:
{{works with|Python|3.7|}}
<
Line 1,525 ⟶ 1,868:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
<pre> Rostt Cod is progrmming chrstomthy sit.
Line 1,536 ⟶ 1,879:
===One liner===
Well, almost........
<syntaxhighlight lang="python">
txt = '''
Rosetta Code is a programming chrestomathy site.
Line 1,546 ⟶ 1,889:
print(''.join(list(filter(lambda a: a not in "aeiou",txt))))
</syntaxhighlight>
{{out}}
<pre>
Line 1,558 ⟶ 1,901:
=={{header|Quackery}}==
<
witheach
[ bit | ] ] constant is vowels ( --> f )
Line 1,569 ⟶ 1,912:
$ '"Beautiful coquettes are quacks of love."'
$ ' -- Francois De La Rochefoucauld' join
disemvowel echo$</
'''Output:'''
Line 1,587 ⟶ 1,930:
Strings from http://mylanguages.org/. No affiliation, but it's a nice resource. (note: these are not all the same sentence but are all from the same paragraph. They frankly were picked based on their vowel load.)
<syntaxhighlight lang="raku"
my $text = q:to/END/;
Line 1,600 ⟶ 1,943:
END
put $text.subst(/@vowels/, ' ', :g);</
{{out}}
<pre>N rw g n, c l nd c, G rm n, T rk sh, Fr nch, Sp n sh, ngl sh:
Line 1,616 ⟶ 1,959:
=== 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.
<
parse arg x /*obtain optional argument from the CL.*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
Line 1,626 ⟶ 1,969:
y= space(translate(y, , vowels), 0) /*trans. vowels──►blanks, elide blanks.*/
y= translate(y, , q) /*trans the Q characters back to blanks*/
say 'output string: ' y /*stick a fork in it, we're all done. */</
{{out|output|text= when using the default input:}}
<pre>
Line 1,635 ⟶ 1,978:
=== using character eliding ===
This REXX version uses a character-by-character manipulation and should be easier to understand.
<
parse arg x /*obtain optional argument from the CL.*/
if x='' | x="," then x= 'REXX Programming Language' /*Not specified? Then use default*/
Line 1,649 ⟶ 1,992:
x= substr(x, 2) /*elide the prefixed dummy character. */
say 'output string: ' x /*stick a fork in it, we're all done. */</
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br>
=={{header|Ring}}==
<
load "stdlib.ring"
str = "Ring Programming Language"
Line 1,663 ⟶ 2,006:
next
see "String without vowels: " + str + nl
</syntaxhighlight>
{{out}}
<pre>
Line 1,669 ⟶ 2,012:
String without vowels: Rng Prgrmmng Lngg
</pre>
=={{header|RPL}}==
≪ "AEIOUaeiou" → string vowels
≪ "" 1 string SIZE '''FOR''' j
string j DUP SUB
'''IF''' vowels OVER POS '''THEN''' DROP '''ELSE''' + '''END'''
'''NEXT'''
≫ ≫ ''''NOVWL'''' STO
{{in}}
<pre>
"This is a difficult sentence to pronounce" NOVWL
</pre>
{{out}}
<pre>
1: "Ths s dffclt sntnc t prnnc"
</pre>
=={{header|Ruby}}==
<
p "Remove vowels from a string".delete("aeiouAEIOU") # => "Rmv vwls frm strng"
</syntaxhighlight>
=={{header|Rust}}==
<
fn remove_vowels(str: String) -> String {
let vowels = "aeiouAEIOU";
Line 1,696 ⟶ 2,055:
println!("{}", remove_vowels(intro));
}
</syntaxhighlight>
Output :
<pre>
Line 1,702 ⟶ 2,061:
Frrs, th crb, s th nffcl msct f th Rst Prgrmmng Lngg
</pre>
=={{header|sed}}==
<syntaxhighlight lang="sed">s/[AaEeIiOoUu]//g</syntaxhighlight>
=={{header|Smalltalk}}==
<
out := in reject:[:ch | ch isVowel].
in printCR.
out printCR.</
{{out}}
<pre>The balloon above harsh harsh waters of programming languages, is the mascot of Smalltalk
Line 1,713 ⟶ 2,075:
As usual, there are many alternative ways to do this:
<
out := in select:[:ch | ch isVowel not].
Line 1,727 ⟶ 2,089:
ch isVowel ifFalse:[ s nextPut:ch ]
]]
</syntaxhighlight>
=={{header|Standard ML}}==
<
CharVector.exists (fn v => c = v) "AaEeIiOoUu"
Line 1,738 ⟶ 2,100:
val str = "LOREM IPSUM dolor sit amet\n"
val () = print str
val () = print (removeVowels str)</
{{out}}
<pre>LOREM IPSUM dolor sit amet
Line 1,744 ⟶ 2,106:
=={{header|Swift}}==
<
switch (char) {
case "a", "A", "e", "E", "i", "I", "o", "O", "u", "U":
Line 1,759 ⟶ 2,121:
let str = "The Swift Programming Language"
print(str)
print(removeVowels(string: str))</
{{out}}
Line 1,768 ⟶ 2,130:
=={{header|Visual Basic .NET}}==
<
Module Module1
Line 1,798 ⟶ 2,160:
End Sub
End Module</
{{out}}
<pre>Input : Visual Basic .NET
Output : Vsl Bsc .NT</pre>
=={{header|V (Vlang)}}==
{{trans|AutoHotkey}}
<syntaxhighlight lang="v (vlang)">fn main() {
mut str := 'The quick brown fox jumps over the lazy dog'
for val in 'aeiou'.split('') {str = str.replace(val,'')}
println(str)
}</syntaxhighlight>
{{out}}
<pre>
Th qck brwn fx jmps vr th lzy dg
</pre>
=={{header|Wren}}==
<
var s = "Wren Programming Language"
System.print("Input : %(s)")
System.print("Output : %(removeVowels.call(s))")</
{{out}}
Line 1,817 ⟶ 2,193:
=={{header|XBS}}==
<
set Vowels:array="aeiou"::split();
set nx:string="";
Line 1,831 ⟶ 2,207:
}
log(RemoveVowels("Hello, world!"));</
{{out}}
<pre>
Line 1,838 ⟶ 2,214:
=={{header|XPL0}}==
<
func Disemvowel(S); \remove vowels from string
Line 1,852 ⟶ 2,228:
];
Text(0, Disemvowel("pack my box with FIVE DOZEN LIQUOR JUGS!"))</
Output:
Line 1,860 ⟶ 2,236:
=={{header|XProfan}}==
<syntaxhighlight lang="xprofan">cls
Set("RegEx",1)
Var string e = "The quick brown fox jumps over the lazy dog"
Var string a = Translate$(e,"(?i)[aeiou]","")
MessageBox("Input : "+e+"\nOutput: "+a,"Remove vowels",1)
End</
{{out}}
<pre>
|