Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Just the vowels please

+4
−0

Given a sequence of letters, output only the vowels.

Input

  • A sequence of letters
  • This may be a string or any ordered data structure of characters (provided it is consistent between inputs)
  • The letters may contain a mixture of upper and lower case
  • The characters that count as letters for this challenge are A-Z and a-z, specifically ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  • The input may be empty (it may have length zero)

Output

  • All of the vowels from the input, in the same order, and nothing else
  • This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
    • For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • Vowels that appear more than once in the input must appear the same number of times in the output
  • If there are no vowels in the input, the output is empty (a sequence of length zero)
  • The characters that count as vowels for this challenge are AEIOUaeiou
  • Case must be maintained - a vowel that is lower case in the input must be lower case in the output, and a vowel that is upper case in the input must be upper case in the output

Test cases

Test cases are in the format "input" : "output"

"" : ""
"q" : ""
"S" : ""
"Rhythm" : ""
"a" : "a"
"art" : "a"
"atr" : "a"
"rat" : "a"
"rta" : "a"
"tar" : "a"
"tra" : "a"
"emu" : "eu"
"eum" : "eu"
"meu" : "eu"
"mue" : "ue"
"uem" : "ue"
"ume" : "ue"
"AaeEIiOouU" : "AaeEIiOouU"
"aaaaaaaa" : "aaaaaaaa"
"bbbbbbbb" : ""
"abababab" : "aaaa"
"babababa" : "aaaa"
"aLtErNaTe" : "aEae"

Explanations are optional, but I'm more likely to upvote answers that have one.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Is `null` a valid output if there are no vowels? (2 comments)

9 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+1
−0

Sclipting, (UTF-16) 22 bytes

놵멡뉖땯더굅낔뭕뇐虛移

Nothing complicated, just replaces the regex [^aeiouAEIOU] with the empty string.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

J, 19 char

Solution:

(e.&'aeiouAEIOU'#])

Test examples:

   (e.&'aeiouAEIOU'#]) ''

   (e.&'aeiouAEIOU'#]) 'Rhythm'

   (e.&'aeiouAEIOU'#]) 'a'
a
   (e.&'aeiouAEIOU'#]) 'emu'
eu
   (e.&'aeiouAEIOU'#]) 'aLtErNaTe'
aEae

How it works:

] is whatever value is on the the far right
# uses boolean value on its left to select from value on its right
'aeiouAEIOU' are the characters being searched for
& ties the value on its right to the verb on its left
e. searches for the values on its right within the value on its left 
   producing a boolean result for found / not found
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Fig, 3 bytes

Actual score is: $3\log_{256}(96)\approx$ 2.469 bytes. Filters consonants from the input string using implicit input.

Fcb

Try it online!

Fcb
F   : Filter with two string args filters a from b
 cb : constant for upper/lowercase consonants
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Vyxal, 2 bytes

~A

Try it Online!

Takes input as a string, outputs a list of vowels.

Explained

~A
~   # Keep only letters from the input where
 A  # the letter is a vowel
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Vyxal, 3 bytes

k∨↔

Try it Online!

  ↔ # Keep chars from
k∨  # vowels
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt v2.0a0, 3 bytes

o\v

Try it

o\v     :Implicit input of string
o       :Keep only
 \v     :RegEx /[aeiou]/gi
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

JavaScript, 27 24 bytes

Input as a string, output as a character array or empty array.

s=>s.split(/[^aeiou]*/i)

Try it online!

Thanks to Moshi for pointing out the * I was missing that would allow me to use split instead of match and get down to 24 bytes.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

24 bytes (4 comments)
+1
−0

Raku, 18 bytes

{m:g:i/<[aeiou]>/}

Implicitly matches the topic variable with the regex

Try it online!

{m:g:i/<[aeiou]>/}
{                }  : anonymous code block
 m                  : match operator
  :g:i              : regex adverbs, global and ignorecase
      /<[aeiou]>/   : the regex using a character class of vowels
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

05AB1E, 3 bytes

žÀÃ

   : implicit input
žÀ : push "aeiouAEIOU"
à : keep all elements of input that occur in "aeiouAEIOU"

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »