- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
He shouda used this:
RemoveSpaces: strItem = StringReplace(" ", " "); if instr(" ") > 0 then goto RemoveSpaces
We don't need no regular expressions!
Admin
Boring!
Admin
And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so.
Admin
No it does not suggest that.
Admin
strItem = StringReplace("Boring!", "WTF!");
Admin
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...
Admin
that must be the reason why his boss is now a manager and not developer anymore.
Admin
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
Admin
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.
Admin
Admin
Hehe. I love regexes too, but I'd never claim that {2,} doesn't look weird.
Admin
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
Admin
Admin
We should probably disambiguate, too, though:
regexReplace(itemDesc, "\s{2,}", " ");
There...that's clearer ;)
Captcha: delenit - the act of removing a nitwit?
Admin
Be careful of using \s in regex as not all platforms support it.
Admin
Boring!
Admin
Admin
Now that's funny!
Admin
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
Admin
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.
Admin
Yes it is.
Shame the comment section has gone downhil so much in general though.
Admin
Clearly, the boss voted for Obama.
Admin
Oh I favore my all time favorite wtf:
no doubt it works ..... ^^
anyway ... I wondered why this "manager" did not fix the problem by increasing the number of spaces ... like
which would drastically increase efficiency !!1oneleven1!
Admin
regexReplace(itemDesc, " +", " "); if you think {2,} looks weird... Or if braces are not supported on an implementation you find yourself using.
Admin
That was supposed to be
but it got eaten.Admin
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...
Admin
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 --
Admin
Admin
Spaces are good. They give the compiler time to think.
Admin
See http://www.research.att.com/~njas/sequences/A159860 and http://www.research.att.com/~njas/sequences/A007501 for the most efficient sequence. In particular, sub-string lengths of 21, 6, 3, 2, and again of 2 spaces will reduce 460 and all shorter sequences of spaces to one space.
Admin
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; }
Admin
Python does also permit such use, but then again, python just uses pcre like many other languages.
Admin
Wow, I made a massive logic error in my code there. Besides the one I made in deciding to write it, I mean.
Admin
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!
Admin
Thanks Russell, for the link to your paper. Much more interesting than today's WTF.
Admin
It's regexp, everything looks wierd.
Admin
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?
Admin
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".
Admin
Admin
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.
Admin
Admin
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 );
Admin
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.
Admin
TRWRTF is that Don was considering just adding another set of StringReplace()! I guess we should be thankful he didn't? Don is "growing."
Admin
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.
Admin
So stop employing just anybody... ;)
Admin
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.
Admin
Just another reason why RegEx Rules!
/ha4@\s+((d)|([t+]h))[3ea4@]\s+p[1l][a4@]n[3e][t+]/i
Admin
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.
Admin
hmm. well, going that way, for efficiency's sake, start with 16 spaces, then 8, 4, 2, and if there are any doubles remaining, loop back to the check for 16
then again, what are they doing that would result in so many contiguous spaces in the description?
http://thedailywtf.com/Articles/No_Line_Breaks_0x3f__Aaaaaaaaaaaaaa!_.aspx