Remove vowels from a string: Difference between revisions

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

edits