Thread:Mathmagician/@comment-3562424-20130324032918/@comment-4674838-20130417022849

6) is partially working, but you have not carefully checked all types of input yet. My looksLikeRegex function was just a suggestion for where to start, not the ends-all solution. Here are some edge cases aren't being handled properly yet:


 * 1) Input: [no input, leave the textfield blank]
 * 2) *Expected result: Input error, delimiter "with" is missing
 * 3) *Actual result: Uncaught TypeError: Cannot call method 'split' of undefined
 * 4) Input:
 * 5) *Expected result: Input error, delimiter "with" is missing
 * 6) *Actual result: Uncaught TypeError: Cannot call method 'split' of undefined
 * 7) Input:
 * 8) *Expected result: Input error, delimiter "with" is missing
 * 9) *Actual result: Replaces "a" with "undefined"
 * 10) Input:
 * 11) *Expected result: Input error, delimiter "with" is missing
 * 12) *Actual result: Replaces "a" with "undefined"
 * 13) Input:
 * 14) *Expected result: Input error,  is not a valid regex because the backslash character   needs to be escaped.
 * 15) *Actual result: Uncaught SyntaxError: Invalid regular expression: /\/: \ at end of pattern

Suggestions:
 * 1) Before you do anything else, check the input field to see if your delimiter "with" is present.
 * 2) *Make sure you throw an input error if the delimiter occurs 0 times.
 * 3) *If the delimiter occurs exactly once, this is good. Proceed.
 * 4) *What do you do if the delimiter occurs more than once? Think about it. Easier option would be to throw an input error. But you could (potentially) also treat it as valid input if handled carefully.
 * 5) If you're going to split the string, think very, very carefully about all the potential outcomes.
 * 6) When you construct the regex, wrap it in a  block to help catch invalid regexes (see #5 above) from causing any errors in the console.