Skip to content

Instantly share code, notes, and snippets.

@westc
Created June 2, 2020 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westc/a917c1d7981c8301baf9309c0847844d to your computer and use it in GitHub Desktop.
Save westc/a917c1d7981c8301baf9309c0847844d to your computer and use it in GitHub Desktop.
Regular Expressions - JavaScript Examples & Python Examples
let rgx = /[aeiou]{2,}/;
let numbers = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"];
let filteredNumbers = numbers.filter(n => rgx.test(n)); // ["Three", "Four"]
rgx = re.compile(r"[aeiou]{2,}")
numbers = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"]
filteredNumbers = [n for n in numbers if rgx.search(n) is not None] # ["Three", "Four"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment