Skip to content

Conversation

@rajashreemaiya
Copy link

@sjreich
Copy link
Contributor

sjreich commented Jan 12, 2016

Assuming this actually passes (I''m too lazy to clone it and everything), 👍 . Two things to clean it up:

  1. calling #split on the string before checking it against the regex will drastically uncomplicate the regex you need.
  2. using the regexp method === instead of String#match is a bit better, because the former returns a boolean directly, whereas the latter returns the index of the match, which gets cast into a boolean.

@rajashreemaiya
Copy link
Author

👍 Noted!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a little curious to try to match on the entire string. You could get away with a way more simple regex, especially since you're sanitizing the input string on line 2. Check out Rubular and you might be surprised how small you can make that matcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants