in reply to Re: Regular Expresion
in thread Regular Expresion

I think his problem isn't the "simple steps", but going from "simple steps" to a "complicated total".

Given that the username may, or may not, preceed the userid, how would you proceed? How would you proceed if there could be 10 fields, in any order?

Replies are listed 'Best First'.
Re^3: Regular Expresion
by apl (Monsignor) on May 14, 2009 at 15:54 UTC
    I wouldn't use one regular expression. I'd use two -- one for the User ID, one for the name. State information tells you if they're both from the same line.

    I realize brevity is the soul of wit, but I occasionally prefer verbosity if it results in ease of support. (Translation: I'm not as good a programmer as the rest of you...)

      By that logic, you would come to the conclusion being a good programmer means everything is a one-liner.

      I disagree. Multiple lines wins except in the case of repeating yourself.
        By that logic, you would come to the conclusion being a good programmer means everything is a one-liner.
        I sometimes get that impression from my fellow Monks; I'm as prone to golfing as the next guy. 8-)
        I disagree. Multiple lines wins except in the case of repeating yourself.
        My sentiment, generally, though I try to merge redundant sequential statements (multiple concatenations, rather than merely breaking a statement over several lines) and prefer ?: over a simple if involving assignments.

        So I guess the line is hard to draw. Why is it okay to use ?:, but not a clever regex?