# Daily Challenge #148 - Disemvowel Trolls

Setup
Trolls are invading the comment section!

To deal with the threat, write a function that takes a string and returns a new string with all vowels removed (y not included).

Example
"This website is for losers LOL!" => "Ths wbst s fr lsrs LL"

Tests
"No newbies allowed, go to #beginners" =>
"LULZ TROLLED" =>

Try to keep it simple. Have fun!

This challenge comes from osuushi on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!

Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!

Posted on by:

### dev.to staff

The hardworking team behind dev.to ❤️

### Discussion

In C#

public static readonly List<Char> LowerCaseVowels = new List<Char> {'a', 'e', 'i', 'o', 'u'};

public static bool IsLowerCaseVowel(this char c) => LowerCaseVowels.Contains(c);

public static string RemoveVowels(string input) =>
new string(input.Where(c => !c.ToLowerInvariant().IsLowerCaseVowel()));


Or may be just

var cleaned = Regex.Replace(input,"[aeiou]", "", RegexOptions.IgnoreCase);

In Ts:

const removeVowels = (text: string) => text.replace(/[aeiou]/gi, '');


Python solution.

def disemvowel(string):
"""Removes all occurences of vowel from the string.

Args:
string (str): The input string.

Returns:
temp_string (str): The resultant string with vowels removed.
"""
final_string = ""
for i in string:
if i.lower() in ["a", "e", "i", "o", "u"]:
continue
else:
final_string += i
return final_string

if __name__ == '__main__':
print(disemvowel("This website is for losers LOL!"), "Ths wbst s fr lsrs LL!")


you could use regex to keep it simple :)

I am yet to study about regexes :)

Here's a Ruby submission!

# Remove all vowels ('y' not included) from a string.
#
# @param [String] the string to strip vowels from
#
# @return [String] the resulting string
def disemvowel(str)
str.split('').select { |ch| !ch.match(/^[aeiou]\$/i) }.join('')
end

puts disemvowel("This website is for losers LOL!")
puts disemvowel("No newbies allowed, go to #beginners")
puts disemvowel("LULZ TROLLED")


Here's a link to the Repl.it: repl.it/@rburmorrison/DevToChallen...

Standard ML of New Jersey Solution


val vowels = [#"a", #"e", #"i", #"o", #"u"]
fun member_of (item, list) = List.exists (fn x => x = item) list
fun disemvowel s = implode (List.filter (fn x => not(member_of(Char.toLower x, vowels))) (explode s))



Elm

module Main exposing (main)

import Char exposing (toLower)
import List exposing (member)
import String exposing (filter)

isForbiddenInsensitive : List Char -> Char -> Bool
isForbiddenInsensitive characterList character =
member (toLower character) characterList

removeVowels : String -> String
removeVowels =
filter <| not << isForbiddenInsensitive [ 'a', 'e', 'i', 'o', 'u' ]


Some unfancy Common Lisp:

(defun remove-vowels (text)
(flet ((vowel-p (char) (find char "aeiouAEIOU" :test #'char=)))
(remove-if #'vowel-p text)))


Liquid syntax error: Unknown tag 'def'

Ruby:

def disemvowel(string)
string.gsub(/[aeiou]/i, "")
end


Python solution 🐍

import re

VOWELS_REGEX = r"[aeiou]"

def removeVowels(message: str) -> str:
return re.sub(VOWELS_REGEX, '', message, flags=re.IGNORECASE)


JS

const disemvowel = (str) => str.replace(/[aeoiu]/gi, '');