Regular Expressions in CoffeeScript are Awesome
21–28 of 28 posts
Re: Regular Expressions in CoffeeScript are Awesome
#22That has nothing to do CoffeeScript, most regex parser implementation support this via a flag. I've seen it done in PHP, Ruby, Perl, Objective-C. For languages whose regular expression engine don't support this, it's easy enough to achieve it via string concatenation.
Re: Regular Expressions in CoffeeScript are Awesome
#23Re: Regular Expressions in CoffeeScript are Awesome
#24In JS you can comment regular expressions, too... :) var foo = new RegExp( '\\d\+' + // First digit '-' + // Delimiter '\\d\+' // Second digit ); foo.test("1234-5432");
True, but then you have the overhead of string concatenation... although in the large scheme of things that is probably very small, unless you are doing it in a huge loop, but then you'd cache that RegExp anyway.
Re: Regular Expressions in CoffeeScript are Awesome
#25Re: Regular Expressions in CoffeeScript are Awesome
#26is there any performance penalty?
Even if they were compiled at runtime, the performance penalty would probably be negligible unless you were randomly compiling the expression in the middle of an inner loop or something equally silly.
Re: Regular Expressions in CoffeeScript are Awesome
#27You shouldn't validate emails by regular expressions since, technically (at least according to spec) "() []:;@,\\\"!#$%&'*+-/=?^_`{}| ~ ? ^_`{}|~."@example.org is a perfectly valid email address [1] [1] http://en.wikipedia.org/wiki/Email_address#Valid_email_addre...
Re: Regular Expressions in CoffeeScript are Awesome
#28"Let's face it, regular expressions aren't for everyone." Wait, since when aren't they? I would have thought basic regex skills were a baseline shibboleth of a programmer. I even know several non-technical people that are proficient.
Jestful, off-the-wall comments aside, I love regex. It takes away a great deal of the drudgery associated with processing volumes and volumes of text. I can't imagine not having it.
(Aside: Now that you mention it, I can think of a couple people who aren't programmers who use regex pretty frequently because it makes their life a little easier even if it isn't highly advanced, super-dense regex.)