Remove vowels from a string: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m syntax highlighting fixup automation |
Added Dart |
||
(28 intermediate revisions by 14 users not shown) | |||
Line 432:
Rmv dfnd sbst f glyphs frm strng.
</pre>
==={{header|BASIC256}}===
<syntaxhighlight lang="
textofinal$ = ""
Line 448 ⟶ 449:
print textofinal$
end</syntaxhighlight>
==={{header|Chipmunk Basic}}===
{{trans|FreeBASIC}}
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="vbnet">100 mensaje$ = "If Peter Piper picked a pack of pickled peppers"+", how many pickled peppers did Peter Piper pick?"
110 textofinal$ = ""
120 for i = 1 to len(mensaje$)
130 c$ = mid$(mensaje$,i,1)
140 select case c$
150 case "a","e","i","o","u","A","E","I","O","U"
160 rem continue for
170 case else
180 textofinal$ = textofinal$+c$
190 end select
200 next i
210 print textofinal$</syntaxhighlight>
==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Public Sub Main()
Dim mensaje As String = "If Peter Piper picked a pack of pickled peppers, how many pickled peppers did Peter Piper pick?"
Dim textofinal As String = ""
Dim c As String
For i As Integer = 1 To Len(mensaje)
c = Mid(mensaje, i, 1)
Select Case c
Case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U"
Continue
Case Else
textofinal &= c
End Select
Next
Print textofinal
End</syntaxhighlight>
==={{header|GW-BASIC}}===
{{works with|PC-BASIC|any}}
{{works with|BASICA}}
{{works with|MSX BASIC|any}}
{{works with|QBasic}}
{{works with|Chipmunk Basic}}
<syntaxhighlight lang="qbasic">10 MS$ = "If Peter Piper picked a pack of pickled peppers, how many pickled peppers did Peter Piper pick?"
20 TF$ = ""
30 FOR I = 1 TO LEN(MS$)
40 C$ = MID$(MS$,I,1)
50 IF C$ <> "a" AND C$ <> "e" AND C$ <> "i" AND C$ <> "o" AND C$ <> "u" AND C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O" AND C$ <> "U" THEN TF$ = TF$ + C$
60 NEXT I
70 PRINT TF$</syntaxhighlight>
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
Same code as [[#GW-BASIC|GW-BASIC]]
==={{header|PureBasic}}===
Line 471 ⟶ 528:
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{works with|QB64}}
<syntaxhighlight lang="qbasic">mensaje$ = "If Peter Piper picked a pack of pickled peppers" + ", how many pickled peppers did Peter Piper pick?"
textofinal$ = ""
c$ =
REM
textofinal$ = textofinal$ + c$
==={{header|Quite BASIC}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">10 LET M$ = "If Peter Piper picked a pack of pickled peppers, how many pickled peppers did Peter Piper pick?"
20 LET T$ = ""
30 FOR I = 1 TO LEN(M$)
40 LET C$ = MID$(M$,I,1)
50 IF C$ <> "a" AND C$ <> "e" AND C$ <> "i" AND C$ <> "o" AND C$ <> "u" AND C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O" AND C$ <> "U" THEN LET T$ = T$ + C$
60 NEXT I
70 PRINT T$</syntaxhighlight>
==={{header|XBasic}}===
{{works with|Windows XBasic}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">PROGRAM "Remove vowels from a string"
VERSION "0.0000"
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
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"
' Skip the vowel
CASE ELSE
textofinal$ = textofinal$ + c$
END SELECT
NEXT i
PRINT textofinal$
END FUNCTION
END PROGRAM</syntaxhighlight>
==={{header|Yabasic}}===
Line 529 ⟶ 623:
{{out}}
<pre>TH QCK BRWN FX jmps vr th lzy dg.</pre>
=={{header|BQN}}==
<syntaxhighlight lang="bqn">Devowel ← ¬∘∊⟜"AaEeIiOoUu"⊸/</syntaxhighlight>
=={{header|C}}==
Line 714 ⟶ 811:
{{out}}
<pre>D Prgrmmng Lngg</pre>
=={{header|Dart}}==
{{trans|C++}}
<syntaxhighlight lang="dart">void main() {
test("Dart Programming Language");
}
class PrintNoVowels {
final String str;
PrintNoVowels(this.str);
@override
String toString() {
StringBuffer buffer = StringBuffer();
for (int i = 0; i < str.length; i++) {
String c = str[i];
switch (c) {
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
break;
default:
buffer.write(c);
break;
}
}
return buffer.toString();
}
}
void test(String s) {
print("Input : $s");
print("Output : ${PrintNoVowels(s)}");
}</syntaxhighlight>
{{out}}
<pre>Input : Dart Programming Language
Output : Drt Prgrmmng Lngg</pre>
=={{header|Delphi}}==
Line 757 ⟶ 899:
After: Th qck brwn fx jmps vr th lzy dg
</pre>
=={{header|EasyLang}}==
<syntaxhighlight lang=text>
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|ed}}==
Solution adapted from [[Strip a set of characters from a string]]
<syntaxhighlight lang="sed">
H
# can also do g/.*/s/[aeiou]//gi on GNU ed
g/.*/s/[aeiouAEIOU]//g
,p
Q
</syntaxhighlight>
{{out}}
<pre>$ cat strip-vowels.ed | ed -lEGs strip-vowels.input
Newline appended
TH QCK BRWN FX jmps vr th lzy dg</pre>
=={{header|F_Sharp|F#}}==
Line 875 ⟶ 1,049:
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}}==
Line 937 ⟶ 1,148:
main :: IO ()
main = putStrLn $ exceptGlyphs "eau" txt</syntaxhighlight>
{{Out}}
Line 949 ⟶ 1,156:
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 = "";
Line 1,275 ⟶ 1,491:
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}}==
Line 1,381 ⟶ 1,604:
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}}==
Line 1,492 ⟶ 1,723:
<pre>The quick brown fox jumps over the lazy dog
Th qck brwn fx jmps vr th lzy dg</pre>
=={{header|Nu}}==
{{works with|Nushell|0.96.1}}
<syntaxhighlight lang="nu">$in | str replace -a -r '(?i)[aeiou]' ''</syntaxhighlight>
=={{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|OmniMark}}==
What is considered a vowel for this task?
# Only English AEIOUaeiou, not Yy?
# ISO-8859-1 vowels? (So, adding, "ÀÁÂÃÄÅÆÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜàáâãäåæèéêëìíîïòóôõöùúûü".)
# Any Unicode plausible vowel, which could include: "ꭤ a ⱥ ⒜" (U+AB64 U+FF41 U+2C65 U+249C) and all sorts of other characters, perhaps even including combining characters like " ͣ" (U+0363)?
Only 1 and 2 have been considered. The lack of `output` after the `find` rules means that the vowels are suppressed and the rest of the input stream is output as-is.
'''''Solution 1'''''
<syntaxhighlight lang="omnimark">
process
submit 'The Quick Brown Fox Jumps Over the Lazy Dog.%n'
find ul ['aeiou']
</syntaxhighlight>
{{out}}
<pre>
Th Qck Brwn Fx Jmps vr th Lzy Dg.
</pre>
'''''Solution 2'''''
<syntaxhighlight lang="omnimark">
macro latin1-vowels is
['AEIOUaeiouÀÁÂÃÄÅÆÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜàáâãäåæèéêëìíîïòóôõöùúûü']
macro-end
process
submit 'AÀÁÂÃÄÅÆThe EÈÉÊËQuick IÌÍÎÏBrown OÒÓÔÕÖØFox UÙÚÛÜJumps ' ||
'aàáâãäåæOver eèéêëthe iìíîïLazy oòóôõöDog.uùúûü%n'
find latin1-vowels
</syntaxhighlight>
{{out}}
<pre>
Th Qck Brwn Fx Jmps vr th Lzy Dg.
</pre>
=={{header|Pascal}}==
Line 1,933 ⟶ 2,210:
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}}==
<syntaxhighlight lang="ruby">
Line 1,966 ⟶ 2,259:
Frrs, th crb, s th nffcl msct f th Rst Prgrmmng Lngg
</pre>
=={{header|sed}}==
<syntaxhighlight lang="sed">s/[AaEeIiOoUu]//g</syntaxhighlight>
=={{header|Smalltalk}}==
Line 2,067 ⟶ 2,363:
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,'')}
Line 2,082 ⟶ 2,378:
=={{header|Wren}}==
<syntaxhighlight lang="
var s = "Wren Programming Language"
|