in reply to Re: Unwrapping values in a template
in thread Unwrapping values in a template

Just so you realize that you've hardcoded a solution for a single data set, whereas some of the other posted solutions are more generalized.

  • Comment on Re: Re: Unwrapping values in a template

Replies are listed 'Best First'.
Re: Unwrapping values in a template
by hacker (Priest) on Nov 15, 2003 at 17:56 UTC
    "Just so you realize that you've hardcoded a solution for a single data set, whereas some of the other posted solutions are more generalized."

    Actually, yes. The "hardcoded" solution provided works in a much larger set of scenarios than the home-grown regex solutions provided. What if there are 200 ^M characters before and after the wrapped key? jeffa's solution handles that (these regexes do not). What if every single key wraps, regardless of width? Again, his solution handles that.

    The other solutions, while unary and interesting on their own, are actually much more "hardcoded" (i.e. will only work on a very small subset of the strings involved) than the solution jeffa provided.

    Can each of the other solutions be modified to work with all scenarios? Yes, sure, but at what cost and maintenance headache a year from now?

    Can jeffa's solution be modified to not be so hard-coded? Yes, and with a much longer-term benefit and maintenance advantage over debugging regexes each time the template format changes ever-so-slightly.

      What if every single key wraps, regardless of width? Again, his solution handles that.

      Really? It doesn't handle even the single extra wrapped key shown in the template in this node.