| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |
|
He shouda used this:
RemoveSpaces: strItem = StringReplace(" ", " "); if instr(" ") > 0 then goto RemoveSpaces We don't need no regular expressions! |
Re: A Spacy Problem
2009-12-07 09:15
•
by
eViLegion
(unregistered)
|
And yet not quite boring enough for you to post a comment, thereby suggesting that your life must be even more so. |
Re: A Spacy Problem
2009-12-07 09:17
•
by
Alekz
(unregistered)
|
No it does not suggest that. |
|
strItem = StringReplace("Boring!", "WTF!");
|
|
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... |
|
that must be the reason why his boss is now a manager and not developer anymore.
|
|
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 |
Re: A Spacy Problem
2009-12-07 09:25
•
by
eViLegion
(unregistered)
|
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. |
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.) |
Re: A Spacy Problem
2009-12-07 09:35
•
by
Spudley
(unregistered)
|
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 |
Re: A Spacy Problem
2009-12-07 09:38
•
by
Anonymous
(unregistered)
|
Question: are you four years old? |
Re: A Spacy Problem
2009-12-07 09:41
•
by
adrian
(unregistered)
|
We should probably disambiguate, too, though: regexReplace(itemDesc, "\s{2,}", " "); There...that's clearer ;) --- Captcha: delenit - the act of removing a nitwit? |
Re: A Spacy Problem
2009-12-07 09:45
•
by
rwbthatisme
(unregistered)
|
Be careful of using \s in regex as not all platforms support it. |
Re: A Spacy Problem
2009-12-07 09:47
•
by
Edward Royce
(unregistered)
|
Boring! |
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. |
Re: A Spacy Problem
2009-12-07 09:56
•
by
Ben Jammin
(unregistered)
|
Now that's funny! |
Re: A Spacy Problem
2009-12-07 09:57
•
by
Spikey
(unregistered)
|
|
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
|
Re: A Spacy Problem
2009-12-07 09:58
•
by
aristos_achaion
(unregistered)
|
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. |
Re: A Spacy Problem
2009-12-07 10:07
•
by
eViLegion
(unregistered)
|
Yes it is. Shame the comment section has gone downhil so much in general though. |
|
Clearly, the boss voted for Obama.
|
|
Oh I favore my all time favorite wtf:
while(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 = which would drastically increase efficiency !!1oneleven1! |
Re: A Spacy Problem
2009-12-07 10:18
•
by
William Clark
(unregistered)
|
regexReplace(itemDesc, " +", " "); if you think {2,} looks weird... Or if braces are not supported on an implementation you find yourself using. |
Re: A Spacy Problem
2009-12-07 10:21
•
by
William Clark
(unregistered)
|
That was supposed to be " +"but it got eaten. |
|
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...
|
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 -- |
So now we need to integrate xml into regular expressions!?
|
|
Spaces are good. They give the compiler time to think.
|
Re: A Spacy Problem
2009-12-07 10:37
•
by
Russell
(unregistered)
|
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. |
|
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; } |
Re: A Spacy Problem
2009-12-07 10:43
•
by
blablablaadje
(unregistered)
|
Python does also permit such use, but then again, python just uses pcre like many other languages. |
|
Wow, I made a massive logic error in my code there. Besides the one I made in deciding to write it, I mean.
|
|
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!
|
Re: A Spacy Problem
2009-12-07 10:50
•
by
Research Paper Reader
(unregistered)
|
Thanks Russell, for the link to your paper. Much more interesting than today's WTF. |
It's regexp, everything looks wierd. |
|
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? |
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". |
So you decided to compensate? You need to learn about Schlemiel the Painter and work out why that applies to your code. |
Re: A Spacy Problem
2009-12-07 11:33
•
by
gallier2
(unregistered)
|
|
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.
|
Re: A Spacy Problem
2009-12-07 11:42
•
by
Brooke
(unregistered)
|
You're right; it doesn't suggest it. It confirms it, just like my life. |
|
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 ); |
Re: A Spacy Problem
2009-12-07 11:56
•
by
Voice of Reason
(unregistered)
|
|
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. |
|
TRWRTF is that Don was considering just adding another set of StringReplace()! I guess we should be thankful he didn't? Don is "growing."
|
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. |
Re: A Spacy Problem
2009-12-07 12:48
•
by
Bubba
(unregistered)
|
So stop employing just anybody... ;) |
Re: A Spacy Problem
2009-12-07 13:10
•
by
Nonymous
(unregistered)
|
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. |
|
Just another reason why RegEx Rules!
/h[a4@](([c\(][k\|<])|(x))\s+((d)|([t\+]h))[3ea4@]\s+p[1l][a4@]n[3e][t\+]/i |
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. |
Re: A Spacy Problem
2009-12-07 13:20
•
by
Patrick
(unregistered)
|
|
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 |
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |