Skip to content

Instantly share code, notes, and snippets.

@tianmingzuo
Created October 23, 2019 02:29
Show Gist options
  • Select an option

  • Save tianmingzuo/be04a634e27eaccc1ad8685263dca2e8 to your computer and use it in GitHub Desktop.

Select an option

Save tianmingzuo/be04a634e27eaccc1ad8685263dca2e8 to your computer and use it in GitHub Desktop.
Check For Mixed Grouping of Characters: If you want to find either Penguin or Pumpkin in a string, you can use the following Regular Expression: /P(engu|umpk)in/g: let testStr = "Pumpkin"; let testRegex = /P(engu|umpk)in/g; testRegex.test(testStr); Fix the regex so that it checks for the names of Franklin Roosevelt or Eleanor Roosevelt in a case…
let myString = "Eleanor Roosevelt";
let myRegex = /(Franklin ([A-Z]\. )?|Eleanor ([A-Z]\. )?)Roosevelt/;
let result = myRegex.test(myString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment