• Steenbergh (unregistered)

    He shouda used this:

    RemoveSpaces: strItem = StringReplace(" ", " "); if instr(" ") > 0 then goto RemoveSpaces

    We don't need no regular expressions!

  • MD (unregistered)

    Boring!

  • eViLegion (unregistered) in reply to MD
    MD:
    Boring!

    And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.

  • Alekz (unregistered) in reply to eViLegion
    eViLegion:
    MD:
    Boring!

    And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.

    No it does not suggest that.

  • Rene (unregistered) in reply to eViLegion

    strItem = StringReplace("Boring!", "WTF!");

  • Mcoder (cs)

    If there is a place to implement a recursive regular expression, that is it :) Way beter than just adding another StringReplace.

    But, unfortunately, he does not seem to be working on Perl, and I know of no other language that permits such abuse on regexes...

  • Michael (unregistered)

    that must be the reason why his boss is now a manager and not developer anymore.

  • NMe (cs)

    Why use character classes in the regular expression if you're only matching a single character anyway?

    regexReplace(itemDesc, " {2,}", " ");

    This would do the exact same thing without looking weird. :P

  • eViLegion (unregistered) in reply to Alekz
    Alekz:
    eViLegion:
    MD:
    Boring!

    And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.

    No it does not suggest that.

    Oh, right, it suggests MD is a nob with nothing better to do that post an unconstructive single word answer, that is neither funny nor clever. And by extension, you are also one of those, for defending him.

  • dkf (cs) in reply to Mcoder
    Mcoder:
    But, unfortunately, he does not seem to be working on Perl, and I know of no other language that permits such abuse on regexes...
    It's not so much regexes at that point, as something that has the same syntax but isn't. (It's actually a context-free language and not a regular language, and so is matched by a different type of automaton. Assuming that nobody's been silly enough to go for the higher-level languages at that point; the complexity there starts to become a bit hard to work with.)
  • Spudley (unregistered) in reply to NMe
    regexReplace(itemDesc, " {2,}", " ");

    This would do the exact same thing without looking weird. :P

    Hehe. I love regexes too, but I'd never claim that {2,} doesn't look weird.

  • NMe (cs) in reply to Spudley
    Spudley:
    Hehe. I love regexes too, but I'd never claim that {2,} doesn't look weird.
    In that case: regexReplace(itemDesc, " +", " ");

    I realize this is different in the way that it also replaces " " with " " whereas my previous suggestion does not, but at least it couldn't look any simpler. :D

  • Anonymous (unregistered) in reply to eViLegion
    eViLegion:
    ...MD is a nob...
    Question: are you four years old?
  • adrian (unregistered) in reply to NMe
    NMe:
    Why use character classes in the regular expression if you're only matching a single character anyway?

    regexReplace(itemDesc, " {2,}", " ");

    This would do the exact same thing without looking weird. :P

    We should probably disambiguate, too, though:

    regexReplace(itemDesc, "\s{2,}", " ");

    There...that's clearer ;)


    Captcha: delenit - the act of removing a nitwit?

  • rwbthatisme (unregistered) in reply to adrian
    adrian:

    regexReplace(itemDesc, "\s{2,}", " ");

    Be careful of using \s in regex as not all platforms support it.

  • Edward Royce (unregistered) in reply to eViLegion
    eViLegion:
    Alekz:
    eViLegion:
    MD:
    Boring!

    And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.

    No it does not suggest that.

    Oh, right, it suggests MD is a nob with nothing better to do that post an unconstructive single word answer, that is neither funny nor clever. And by extension, you are also one of those, for defending him.

    Boring!

  • NMe (cs) in reply to adrian
    adrian:
    We should probably disambiguate, too, though:

    regexReplace(itemDesc, "\s{2,}", " ");

    There...that's clearer ;)

    Depends on the actual situation I guess. From what I gather out of the article, it's always a space in machine generated code. You can get away without disambiguation in situations like that.

  • Ben Jammin (unregistered) in reply to Edward Royce
    Edward Royce:
    eViLegion:
    Alekz:
    eViLegion:
    MD:
    Boring!

    And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.

    No it does not suggest that.

    Oh, right, it suggests MD is a nob with nothing better to do that post an unconstructive single word answer, that is neither funny nor clever. And by extension, you are also one of those, for defending him.

    Boring!

    Now that's funny!

  • Spikey (unregistered) in reply to adrian

    erm.. that may have unintended consequences, \s means any whitespace character not just space, gotta be carefull and make sure it does only what you want

  • aristos_achaion (unregistered) in reply to Spudley
    Spudley:
    regexReplace(itemDesc, " {2,}", " ");

    This would do the exact same thing without looking weird. :P

    Hehe. I love regexes too, but I'd never claim that {2,} doesn't look weird.

    Though, honestly, it looks less weird than itemDesc =~ s/[ ]{2}/ /g

    TRWTF is that, not being written in Perl, this doesn't look like a cartoon character swearing, as God intended regexes to look.

  • eViLegion (unregistered) in reply to Ben Jammin
    Ben Jammin:
    Edward Royce:
    Boring!

    Now that's funny!

    Yes it is.

    Shame the comment section has gone downhil so much in general though.

  • Bubba (unregistered)

    Clearly, the boss voted for Obama.

  • James T. (unregistered)

    Oh I favore my all time favorite wtf:

    while(itemDesc != stringReplace(itemDesc, "  ", " ")) {
      itemDesc = stringReplace(itemDesc, "  ", " ");
    }

    no doubt it works ..... ^^

    anyway ... I wondered why this "manager" did not fix the problem by increasing the number of spaces ... like

    itemDesc = 
     stringReplace(
      stringReplace(
       stringReplace(
        stringReplace(
         stringReplace(
          stringReplace(
           /* [...] snip for sanity */
           itemDesc,
           /* [...] yet another snip */
           "       ", " "),
          "      ", " "),
         "     ", " "),
        "    ", " "),
       "   ", " "),
      "  ", " ");

    which would drastically increase efficiency !!1oneleven1!

  • William Clark (unregistered) in reply to aristos_achaion
    Spudley:
    regexReplace(itemDesc, " {2,}", " ");

    This would do the exact same thing without looking weird. :P

    Hehe. I love regexes too, but I'd never claim that {2,} doesn't look weird.

    regexReplace(itemDesc, " +", " "); if you think {2,} looks weird... Or if braces are not supported on an implementation you find yourself using.

  • William Clark (unregistered) in reply to William Clark
    William Clark:
    regexReplace(itemDesc, " +", " "); if you think {2,} looks weird... Or if braces are not supported on an implementation you find yourself using.

    That was supposed to be

    "  +"
    but it got eaten.

  • justsomedude (unregistered)

    TRWTF is allowing free-form field entries on a value that's getting fed to a 3rd party and is expected to match known possibles. Should be limited to list...

  • luis.espinal (cs) in reply to Steenbergh
    Steenbergh:
    He shouda used this:

    RemoveSpaces: strItem = StringReplace(" ", " "); if instr(" ") > 0 then goto RemoveSpaces

    We don't need no regular expressions!

    Goto? Dude, what the...? Of all the things considering that DO/WHILE loops have existed since BASIC dialects evolved out of the GW-BASIC/PICK-BASIC/TARD-BASIC decades ago? Goto? Worst fix ever. I hope that was a joke.

    As for the code snippet featured in the article, it is not surprising at all. It happens a lot, not only on VB, but on Java and C#. It almost makes me want to see programming licenses being mandatory to do perform any programming job or rigorous across-the-board examination exams mandatory for graduating with a CS or MIS degree... almost.

    These type of WTFs are not just due to not knowing the language, but they display a fundamental flaw on the way of thinking and problem-solving, completely inexcusable.

    -- second try --

  • snoofle (cs) in reply to rwbthatisme
    rwbthatisme:
    adrian:

    regexReplace(itemDesc, "\s{2,}", " ");

    Be careful of using \s in regex as not all platforms support it.

    So now we need to integrate xml into regular expressions!?

    regexReplace(itemDesc, "<doc><charType> </charType></doc>{2,}", " ");
    
  • Bubba (unregistered)

    Spaces are good. They give the compiler time to think.

  • Russell (unregistered) in reply to James T.
    Comment held for moderation.
  • Anonymously Yours (unregistered)

    His boss should have resolved the problem by writing a script to write the script for him. It probably would have resembled this...

    function genRepCodeForScriptWriter(intVersion) { strAnyCode = '';

    //Double the number of string replaces for each iteration after the first, because that makes sense. for(i = 0; i < intVersion; i++) { strAnyCode = strAnyCode + "\n\tstringReplace("; }

    //Squash itemDesc in the middle strAnyCode = strAnyCode + "\n\t\titemDesc";

    for(i = 0; i < intVersion; i++) { strAnyCode = strAnyCode + ",\n\t" + '" ", " ")'; }

    //Wrap things up. Man, there is no easier way to do this. strAnyCode = "// pull double spaces\nitemDesc = " + strAnyCode + ';';

    return strAnyCode; }

  • blablablaadje (unregistered) in reply to Mcoder
    Mcoder:
    If there is a place to implement a recursive regular expression, that is it :) Way beter than just adding another StringReplace.

    But, unfortunately, he does not seem to be working on Perl, and I know of no other language that permits such abuse on regexes...

    Python does also permit such use, but then again, python just uses pcre like many other languages.

  • Anonymously Yours (unregistered)

    Wow, I made a massive logic error in my code there. Besides the one I made in deciding to write it, I mean.

  • Neville Flynn (unregistered)

    The appropriate thing to do in this economic environment with rising unemployment would have been to hire a data entry clerk to delete the spaces!

  • Research Paper Reader (unregistered) in reply to Russell
    Comment held for moderation.
  • DT (unregistered) in reply to NMe
    NMe:
    Why use character classes in the regular expression if you're only matching a single character anyway?

    regexReplace(itemDesc, " {2,}", " ");

    This would do the exact same thing without looking weird. :P

    It's regexp, everything looks wierd.

  • Voice of Reason (unregistered)

    There's far too much "clever" in these comments...

    None of the RegEx is completely clear (it never is), nor is it remotely necessary.

    while (itemDesc.indexOf(" ") != -1) { itemDesc = StringReplace(itemDesc, " ", " ") };

    Or was that too readable?

  • realmerlyn (cs) in reply to blablablaadje
    blablablaadje:
    Python does also permit such use, but then again, python just uses pcre like many other languages.

    The joke there is that PCRE is not Perl Compatible, except in name. :) Should have been called "somewhat Perl Compatible" or maybe "Perl inspired". And until the PCRE lib embeds a full Perl interpreter, it'll never be truly "Perl Compatible".

  • dkf (cs) in reply to Voice of Reason
    Voice of Reason:
    There's far too much "clever" in these comments...
    So you decided to compensate?
    Voice of Reason:
    while (itemDesc.indexOf("  ") != -1) 
    { 
       itemDesc = StringReplace(itemDesc, "  ", " ") 
    };
    You need to learn about Schlemiel the Painter and work out why that applies to your code.
  • gallier2 (unregistered) in reply to dkf

    What I thought at first look, but the complexity of his function is not quadratic (Schlemiel is O(n²)). It's less than that because StringReplace replaces more than 1 double white in each loop.

  • Brooke (unregistered) in reply to Alekz
    Alekz:
    eViLegion:
    MD:
    Boring!

    And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.

    No it does not suggest that.

    You're right; it doesn't suggest it. It confirms it, just like my life.

  • gus (unregistered)

    Dudes, it gets worse than this. At my last POE there were dozens of occurrences of:

    while pos( ' ', Line ) > 0 do Delete( Line, pos( ' ', Line), 1 );

  • Voice of Reason (unregistered) in reply to dkf

    Oh, I bow to your in-depth understanding of the implementation of your particular RegEx library.

    Or, are you depending on the "Clever-Optimization" support that they're including new CPUs?

    Perhaps the real "Schlemiel" is assuming that an unknown implementation is faster that the direct route. Maybe you're right, but, it'll vary widely, and you certainly can't fault code that's clearer and may not be any slower.

  • NetBiter (unregistered)

    TRWRTF is that Don was considering just adding another set of StringReplace()! I guess we should be thankful he didn't? Don is "growing."

  • amischiefr (cs) in reply to luis.espinal
    luis.espinal:
    Steenbergh:
    He shouda used this:

    RemoveSpaces: strItem = StringReplace(" ", " "); if instr(" ") > 0 then goto RemoveSpaces

    We don't need no regular expressions!

    Goto? Dude, what the...? Of all the things considering that DO/WHILE loops have existed since BASIC dialects evolved out of the GW-BASIC/PICK-BASIC/TARD-BASIC decades ago? Goto? Worst fix ever. I hope that was a joke.

    As for the code snippet featured in the article, it is not surprising at all. It happens a lot, not only on VB, but on Java and C#. It almost makes me want to see programming licenses being mandatory to do perform any programming job or rigorous across-the-board examination exams mandatory for graduating with a CS or MIS degree... almost.

    These type of WTFs are not just due to not knowing the language, but they display a fundamental flaw on the way of thinking and problem-solving, completely inexcusable.

    -- second try --

    Why almost? I think they should. You can't practice Law without a degree, you can't perform operations without a medical degree (legally anyway, which goes back to point 1...). Why not institute a similar practice for programming?

    Oh right, because 1/2 of the tards out there are lazy, uneducated fucks that think because they write stupid script in their mother's basement that qualifies them as a programmer.

    Yes I know, there are some talented guys out there that don't have a degree, yada yada, some exceptions to the rule, yada yada. And I'm pretty sure that there are people who could be good trial lawyers that can't get into Law school because they don't have the money or can't do well on the LSAT. But guess what? We don't let them practice law! And we shouldn't let just anybody write code.

    Just my rant.

  • Bubba (unregistered) in reply to amischiefr
    amischiefr:
    ...we shouldn't let just anybody write code...

    So stop employing just anybody... ;)

  • Nonymous (unregistered) in reply to amischiefr
    amischiefr:
    Why almost? I think they should. You can't practice Law without a degree, ...

    Some states let you take the Bar exam without having a degree, and some states don't even require you to take the Bar exam to practice law (voluntary membership in the Bar).

    Not that I disagree with you, but Law is not the best example of your point.

  • Patrick (unregistered)
    Comment held for moderation.
  • wee (cs) in reply to adrian
    adrian:
    We should probably disambiguate, too, though:

    regexReplace(itemDesc, "\s{2,}", " ");

    I was thinking the same thing, but if it's only one pattern that is only a couple characters long, I'd use something literal, like this:

    regexReplace(itemDesc, " ", " ");

    That looks much clearer to me, as I immediately know what you are aiming to do.

    Additionally, the problem with using \s is that it'll match spaces, tabs, newlines, carriage returns, etc. So if that "\s{2,}" regex is run across a document created/saved on a Windows platform, it'd replace any blank lines with spaces (by matching Windows' carriage return/linefeed line endings). That's probably not what you want.

  • Patrick (unregistered) in reply to James T.
    Comment held for moderation.

Leave a comment on “A Spacy Problem”

Log In or post as a guest

Replying to comment #:

« Return to Article