Whoa there! Like it says in the title, this is a stupid regex trick. It's not production code, nor did I pass it off as such; the regex itself for example doesn't stand up to certain types of numbers. I can write clean production code but clean that kind of mind numbing code day-in-day-out-3-for-loops-instead-of-a-Schwartzian-tranform-stuff is not interesting (to me) for discussions.

Update: (As the snippet says, this is "play" and not trying to solicit "fixed" code but more samples, which I'd still love to see, of what's possible within a regex, not what's correct in one's particular code style estimation. And I believe almost all code is worth commenting out.)


In reply to "Point, not, point, not, point, watch the beat!" by Your Mother
in thread mile/kilometer converter (category: stupid regex tricks) by Your Mother

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.