Community Member Profile
- Profile: /members/2107-Steven-Levithan.htm
- URL: http://blog.stevenlevithan.com
- Comments: 165
- Points: 31
Recent Blog Comments By Steven Levithan
-
Ask Ben: Javascript String Replace Method
Posted on Feb 21, 2010 at 12:20 PM
@Wize, the details of what you're trying to do are not clear to me. E.g., what's the deal with matching "rem" case insensitively (are you trying to harmonize the casing?) and do you only want to replace the first single quote (that is not enclosed in double quotes) on each line? Anyway, wha... read more »
-
The Regular Expression Cookbook By Steven Levithan And Jan Goyvaerts
Posted on Jul 27, 2009 at 1:15 PM
Thanks, Ben (and Craig)! I've got to give props to coauthor Jan Goyvaerts though, who wrote a lot of the sections that you referenced.... read more »
-
ColdFusion Email Validation, IsValid(), And CFMail Errors
Posted on Jul 18, 2009 at 5:24 PM
@Ben Nadel, yes, it's valid according to RFC 2822--the special characters allowed as part of an email address's username are _!#$%&'*+/=?`{|}~^.-. At my last job I ran into single quotes in email addresses a lot. It's unfortunate that a lot of naïve validation (including CF's isValid, etc.) disal... read more »
-
Ask Ben: Converting Javascript Lists To Arrays
Posted on Nov 5, 2008 at 4:12 PM
@Rohit, using capturing parentheses in your split pattern probably didn't work for you since you're using Internet Explorer, which doesn't follow the JavaScript split specification on that point. It will work if you first run the following script, which fixes String.prototype.split cross-browser:... read more »
-
Got My Sweet-Ass T-Shirts From Steven Levithan's Regular Expression Contest
Posted on Sep 13, 2008 at 7:48 PM
Coolness! Way to bring out the secret admirers. ;)... read more »
-
Partial Entry For Steve Levithan's Regular Expression Contest
Posted on Jun 13, 2008 at 10:48 AM
Nice. Wow, you put a lot of work into that... more than I was expecting from contestants. Parsing XML with regular expressions is something I've wanted to take a stab at for a long time since it sounds like a lot of fun (even though there are established implementations and possibly better approa... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 29, 2008 at 5:17 PM
@Ben Doom, lolz. :) (Again, not a Perl hacker, but replacements are done with s/// [s stands for substitution].)... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 29, 2008 at 4:38 PM
@Ben Doom, I'm not a Perl hacker, but I know that adding the "m" in `i =~ m/(^)(?:.*)($)/;` doesn't change anything. Some people have a preference to always use it, or not. @Eric, the parens and the bit about some adjustments being in the spirit of xkcd/208 threw me off, but "I am the alpha... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 29, 2008 at 2:53 PM
@Eric, how do you read those? I'm sure I'm missing the joke.... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 29, 2008 at 6:03 AM
@Jane, I haven't posted what prize I'm interested in, so I'm not in the running (intentionally).... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 29, 2008 at 5:43 AM
Thanks for starting this, Ben. I've posted my own regex contest / giveaway at http://blog.stevenlevithan.com/archives/regexday-2008 . Of course, everyone here is welcome to participate there as well.... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 28, 2008 at 2:15 PM
@Ben, yes. More specifically, it's what I call a capturing-group-participation-based conditional, which is a bit of a mouthful (and is not official terminology for any particular regex flavor). For the sake of deriving some kind of meaning, I suggest you read the regex as "If match 'me', ma... read more »
-
June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)
Posted on May 28, 2008 at 1:26 PM
> post a comment below [...] on how > much you like regular expressions I will express my love in regex. (?i)(me)?(?(1)\u2665((?:reg(?:ular expressions?|ex(?:p|e[ns])?)))|(?!))(?>\1\2) @Eric, I've debugged that shirt, too. See: read more »
-
REMatchGroup() UDF To Return Only Specified Group In RegEx Pattern
Posted on Jan 30, 2008 at 5:32 PM
It is derivative. A prime example is the very issue we're discussing. The latest versions of WebKit implement the correct ECMAScript handling for backreferences to non-participating groups (they always match), which is different from PCRE's native handling (they never match). I'm not trying... read more »
-
REMatchGroup() UDF To Return Only Specified Group In RegEx Pattern
Posted on Jan 30, 2008 at 4:33 PM
What is a PCRE-based engine? The only engine I can think of which that accurately describes is the one included in JavaScriptCore, the JavaScript engine for WebKit implementations such as the Safari browser. If you're using "PCRE-based" to describe popular Perl-derivative regex engines, I can tel... read more »
-
REMatchGroup() UDF To Return Only Specified Group In RegEx Pattern
Posted on Jan 30, 2008 at 4:14 PM
And by the way, I would not recommend using stuff like /(?:foo) \1 (bar)/ even for illustrative purposes unless you know exactly what you're doing, because it's bound to cause confusion. The meaning varies between regex flavors and even specific implementations and versions of the same standards.... read more »
-
REMatchGroup() UDF To Return Only Specified Group In RegEx Pattern
Posted on Jan 30, 2008 at 4:05 PM
@Elliott, Ben was talking about the entire match (backreference 0), where the values certainly will show up. Backreference values are not exactly convenient to get at with ColdFusion. You have to mid() them out the original string using the result of reFind() with the returnSubExpressions argumen... read more »
-
REMatchGroup() UDF To Return Only Specified Group In RegEx Pattern
Posted on Jan 29, 2008 at 11:32 PM
There are four approaches to lookbehind: - No lookbehind. The state of affairs in e.g. JavaScript, ColdFusion, and Ruby. - Fixed length. This is what you get in Perl and Python. With fixed-length lookbehind, (?<=a|ab) is invalid, as is the use of any kind of quantifier within the lo... read more »
-
Ask Ben: Delete Values In A Given List Using ColdFusion
Posted on Jan 29, 2008 at 7:59 AM
Ah, Ben covered the special character issue... hadn't seen his comment when I responded. BTW, when I said regexes are the obvious solution, that's because I'm a regex nut. I hope that didn't come across in a condescending way. But yeah, in the majority of cases a simple replaceList or reRep... read more »
-
Ask Ben: Delete Values In A Given List Using ColdFusion
Posted on Jan 29, 2008 at 7:33 AM
Yes, REReplace is the obvious solution, but it seems needlessly brittle here because it requires that you either know your data or take a bunch of precautions. For example, you can't just embed the delimiters and characters to remove into your regex without either writing them in regex syntax to... read more »



