• (cs)

    It's still shorter than the complete email regex...

  • (cs)

    frist! Okay, I have a very similar procedure, but it's nowhere near that complicated. but if it works, it works.

  • Fisty Mc Fistassin (unregistered)

    Holy Shit! How did I get beaten!

    Third FIST!

  • Greg (unregistered)

    Oh yeah. Reminds me of the time I found&removed a 300 line strong method that was supposed to check if the difference between a given date and "now" exceeds 18 years (an enterprisey java "are you over 18?" check)

  • (cs)

    You gol-danged whipper-snapper kids and your uppity "methods" should shut up and learn the REAL way to code, like we did back in the day! Ha, "split", you're just begging for trouble by letting some fancy LIBRARY routine do the work for you, ya slacker! How do you know it will work right unless you write the code yourself?? Huh?? Got no answer for that, do you, Mister Smarty-Pants!

  • Anonymous (unregistered)

    I was thinking, hey I know the guy who wrote this but then I realized it was missing his trademark ... if (doneCur == true)

  • Inhibeo (unregistered) in reply to TarquinWJ
    if (allDone)
        break;

    How zen.

  • (cs)

    Sure, it's a WTF. I'm not gonna say it's not a WTF.

    But these modern day compiler libraries are so incredibly large, it's impossible to know, and understand, and be able to use, every single call that's included. It would take years, if not decades, for a programmer to get to know all the ins and outs of a given library. And then in the end, when he knows everything, he'll find that his knowledge is outdated and there are newer versions of the libraries with different functionalities.

    So the best you can aspire to is to learn a decent subset of the calls at your disposal, and to use those to the best of your abilities.

    If, at every routine I'm writing, I were to think, hey, maybe there's an API call somewhere that does the same thing; why don't I just launch a quick internet search and spend the afternoon surfing across msdn.microsoft.com, my programs would take much longer to write, even if they would end up marginally smaller.

  • Rollerscopter (unregistered) in reply to Pim

    Yeah right, cause string.Split() is an obscure, rarely-used method.

  • Anon (unregistered)
    return emails.Split(' ', '\t', ',', ';', ':');

    Shouldn't that be:

    return emails.Split(new char[]{' ','\t',',',';',':'});

  • NoXzema (unregistered) in reply to Pim
    Pim:
    Sure, it's a WTF. I'm not gonna say it's not a WTF.

    But these modern day compiler libraries are so incredibly large, it's impossible to know, and understand, and be able to use, every single call that's included. It would take years, if not decades, for a programmer to get to know all the ins and outs of a given library. And then in the end, when he knows everything, he'll find that his knowledge is outdated and there are newer versions of the libraries with different functionalities.

    So the best you can aspire to is to learn a decent subset of the calls at your disposal, and to use those to the best of your abilities.

    If, at every routine I'm writing, I were to think, hey, maybe there's an API call somewhere that does the same thing; why don't I just launch a quick internet search and spend the afternoon surfing across msdn.microsoft.com, my programs would take much longer to write, even if they would end up marginally smaller.

    The reason you would do this is:

    1. It usually doesn't take as much time to find than it does to code.
    2. The API function you call would end up being so much more effecient even if it were a little time loss.
    3. It would make your code so much more enjoyable to read and have already placed documentation (most of the time).
  • sagaciter (rocking the captchah, rocking the captchah...) (unregistered)

    This is typical of Java mistraining:

    • some manager thaught that this new-fangled java thing is cool, let's train the dev's on it, etc. etc.
    • the a st**pid fail-training train comes, and gives the course on java as a language alone (look ma, garbage collection, weak references, whohoo !), when actually knowing what's inside the java libraries should be 4/5 of it. (sigh...) been there, seen that, should have created a tee-shirt, would be rich by now.
  • Abraham Maslow (unregistered)

    He that is good with a hammer tends to think everything is a nail.

  • Mike (unregistered)

    Speed up loop?

    for (i = 0; i < len; i++)
    {
        char ch = emails[i];
    }
    
  • Anon (unregistered) in reply to Anon
    Anon:
    return emails.Split(' ', '\t', ',', ';', ':');

    Shouldn't that be:

    return emails.Split(new char[]{' ', '\t', ',' ,';' ,':'});
    

    Ok, that's more readable.

  • FromCanada (unregistered)

    Comment<string> comment = new Comment<string>(1);

  • (cs) in reply to sagaciter (rocking the captchah, rocking the captchah...)
    sagaciter (rocking the captchah:
    • the a st**pid fail-training train

    The what?

  • (cs) in reply to Bobbo
    Bobbo:
    • the a st**pid fail-training train

    The what?

    You know, those two-letter words that nobody likes to see on TV. Like... I guess.... uu in this case?

  • 50% Opacity (unregistered) in reply to Bobbo
    Bobbo:
    sagaciter (rocking the captchah:
    • the a st**pid fail-training train

    The what?

    I have no idea, but I sure gonna use this one from now on.

  • Abraham Maslow (unregistered)

    To the man who only has a hammer, everything he encounters begins to look like a nail.

  • Edward Royce (unregistered) in reply to dpm
    dpm:
    You gol-danged whipper-snapper kids and your uppity "methods" should shut up and learn the REAL way to code, like we did back in the day! Ha, "split", you're just begging for trouble by letting some fancy LIBRARY routine do the work for you, ya slacker! How do you know it will work right unless you write the code yourself?? Huh?? Got no answer for that, do you, Mister Smarty-Pants!

    Get off my lawn!!

  • SCB (unregistered) in reply to Bobbo
    Bobbo:
    sagaciter (rocking the captchah:
    • the a st**pid fail-training train

    The what?

    stoopid

  • augur (unregistered) in reply to Anon
    Anon:
    return emails.Split(' ', '\t', ',', ';', ':');

    Shouldn't that be:

    return emails.Split(new char[]{' ','\t',',',';',':'});

    Or:

    return emails.Split(" \t,;:".ToCharArray());

  • (cs) in reply to Anon
    Anon:
    return emails.Split(' ', '\t', ',', ';', ':');

    Shouldn't that be:

    return emails.Split(new char[]{' ','\t',',',';',':'});

    The argument for Split is params char[] so the call from the article is correct and the easiest to use.

  • monkeyPushButton (unregistered) in reply to SCB
    SCB:
    Bobbo:
    sagaciter (rocking the captchah:
    • the a st**pid fail-training train

    The what?

    stoopid

    Thanks for making this thread not work safe.
  • Edward Royce (unregistered) in reply to Rollerscopter
    Rollerscopter:
    Yeah right, cause string.Split() is an obscure, rarely-used method.

    It's a funny thing.

    When I was a very young kid and having just learned the basics of English, got adopted into an American family, I spent weeks reading dictionaries from cover to cover so I could have a better understanding of the language.

    Yet there are professional programmers who learn the syntax of a language but don't bother furthering their understanding of all the functions and objects available for that language.

    strange.

  • guh (unregistered) in reply to Pim
    Pim:
    Sure, it's a WTF. I'm not gonna say it's not a WTF.

    But these modern day compiler libraries are so incredibly large, it's impossible to know, and understand, and be able to use, every single call that's included. It would take years, if not decades, for a programmer to get to know all the ins and outs of a given library. And then in the end, when he knows everything, he'll find that his knowledge is outdated and there are newer versions of the libraries with different functionalities.

    So the best you can aspire to is to learn a decent subset of the calls at your disposal, and to use those to the best of your abilities.

    If, at every routine I'm writing, I were to think, hey, maybe there's an API call somewhere that does the same thing; why don't I just launch a quick internet search and spend the afternoon surfing across msdn.microsoft.com, my programs would take much longer to write, even if they would end up marginally smaller.

    Or you could just type emails.'Ctrl-Space'

  • (cs) in reply to augur
    augur:
    Anon:
    return emails.Split(' ', '\t', ',', ';', ':');

    Shouldn't that be:

    return emails.Split(new char[]{' ','\t',',',';',':'});

    Or:

    return emails.Split(" \t,;:".ToCharArray());

    Yes, except it is then harder to read; on first glance (not had coffee yet)

    " \t,;:".ToCharArray() would return [' ','','t',',',';',':']

    The original is more readable and is less typing; what's not to like (unless you're a Complicator, of course)?

  • (cs) in reply to monkeyPushButton
    monkeyPushButton:

    snip

    Thanks for making this thread not work safe.

    Yes, but is your work thread-safe??

  • Anon (unregistered)

    FYI to all the java programmers providing solutions, the method is

    split
    and not
    Split
    and on top of that it doesn't take character array as an argument.

  • (cs) in reply to Edward Royce
    Edward Royce:
    Rollerscopter:
    Yeah right, cause string.Split() is an obscure, rarely-used method.

    It's a funny thing.

    When I was a very young kid and having just learned the basics of English, got adopted into an American family, I spent weeks reading dictionaries from cover to cover so I could have a better understanding of the language.

    Yet there are professional programmers who learn the syntax of a language but don't bother furthering their understanding of all the functions and objects available for that language.

    strange.

    So how many of the 540,000 words in the English language do you know?

    Did you know that the "acnestis" is the part of the back that's impossible to scratch?

    No? I didn't either until I looked it up - but I managed before by saying "that bit just behind my shoulder blades that I can't scratch". OK it was a bit long winded, but in many ways it's easier to communicate with people the long-winded way, rather than using an obscure word which you'd probably end up having to explain the meaning of anyway.

    :)

  • Dr. Evil (unregistered) in reply to Mr B
    Mr B:
    Edward Royce:
    Rollerscopter:
    Yeah right, cause string.Split() is an obscure, rarely-used method.

    It's a funny thing.

    When I was a very young kid and having just learned the basics of English, got adopted into an American family, I spent weeks reading dictionaries from cover to cover so I could have a better understanding of the language.

    Yet there are professional programmers who learn the syntax of a language but don't bother furthering their understanding of all the functions and objects available for that language.

    strange.

    So how many of the 540,000 words in the English language do you know?

    Did you know that the "acnestis" is the part of the back that's impossible to scratch?

    No? I didn't either until I looked it up - but I managed before by saying "that bit just behind my shoulder blades that I can't scratch". OK it was a bit long winded, but in many ways it's easier to communicate with people the long-winded way, rather than using an obscure word which you'd probably end up having to explain the meaning of anyway.

    :)

    Maybe so, but string.Split() is the nose on your face, not the acnestis on your back :)

  • Fishbone (unregistered)

    i could be wrong, but i don't think, that "List<string> list = new List<string>(1);" would compile at all... List is an Interface and thus is not instantiable.

  • Tim (unregistered)

    I'm pretty sure this is C# code, not Java.

    I don't know C# - can you really call a function that takes a Char[] by passing the chars as separate parameters?

    How does it deal with this:

    void func(Char[] foo); void func(Char a, Char b);

    ...

    func('a', 'b');

  • (cs)
    couldn't you just has easily have bought a screwdriver
    You make Fuhrer angry.
  • Fishbone (unregistered) in reply to Tim
    Tim:
    I'm pretty sure this is C# code, not Java.
    ok, that would render my comment useless...
  • Steve (unregistered) in reply to Fishbone

    It's C#, you can use List<string>, IList is the interface.

  • Lol Lolovici (unregistered) in reply to Mr B
    Mr B:
    Did you know that the "acnestis" is the part of the back that's impossible to scratch?

    No? I didn't either until I looked it up - but I managed before by saying "that bit just behind my shoulder blades that I can't scratch". OK it was a bit long winded, but in many ways it's easier to communicate with people the long-winded way, rather than using an obscure word which you'd probably end up having to explain the meaning of anyway.

    :)

    So are you saying that it's easier when you talk to people to say "Moses did that action that applied to an object creates several subparts of that object to the waters" instead of "Moses split the waters"?

  • Bart (unregistered) in reply to Pim

    A "decent subset" of the Java library should include String.split, or it is not "decent".

    Learning all of the libraries for a language such as Java is not feasible; however, any developer should imho try to constantly expand the tools (i.e. the "decent subset of calls" ) at his disposal. If what you are trying to code seems like something that should be in a library, chances are it is in the library, but you just did not find it yet.

  • Joe (unregistered) in reply to Beldar the Phantom Replier
    Beldar the Phantom Replier:
    augur:
    Anon:
    return emails.Split(' ', '\t', ',', ';', ':');

    Shouldn't that be:

    return emails.Split(new char[]{' ','\t',',',';',':'});

    Or:

    return emails.Split(" \t,;:".ToCharArray());

    Yes, except it is then harder to read; on first glance (not had coffee yet)

    " \t,;:".ToCharArray() would return [' ','','t',',',';',':']

    The original is more readable and is less typing; what's not to like (unless you're a Complicator, of course)?

    Except '\t' is a tab character.

    I guess you could verbatim the string (@".."); but, string -> char[] is not the best way anyhow. I'm not going to hate-on splitting a string to char[] since it is useful in some cases. This is not one of those cases.

    You sir, are The Complicator. "new char[] { ... }" is the way to go.

  • jcs (unregistered)

    Wake up people...this is obviously C#, not Java! The uppercase method names should have given it away.

  • jcs (unregistered)

    Tim: You cannot do that -- you must actually create an array.

  • (cs) in reply to Tim
    Tim:
    I'm pretty sure this is C# code, not Java.

    I don't know C# - can you really call a function that takes a Char[] by passing the chars as separate parameters?

    How does it deal with this:

    void func(Char[] foo); void func(Char a, Char b);

    ...

    func('a', 'b');

    in C#, if the signature is: func(params char[] foo); the params keyword allows you to invoke it by passing the chars as separate parameters, and you treat it as an array inside the function.

    func('a','b'); will invoke the signature that explicitly matches your call, but func('a','b','c') will invoke the overload with the params keyword.

  • jcs (unregistered)

    To the "programmers" who complain that the class libraries are too large for them to discover functions like String.Split ... nobody's asking you to memorize the entire class library, but every programmer SHOULD be familiar with the most fundamental classes in the library (such as Object, String, and the collections framework) and the methods that are available for these classes.

    If you can't even be bothered to learn the methods for String (one of the most commonly used classes in the language), then why is your employer paying you again?

  • (cs) in reply to jcs

    Because the employer charges the customer by the hour and/or lines of code?

  • Anon (unregistered) in reply to Tim
    Tim:
    I'm pretty sure this is C# code, not Java.

    I don't know C# - can you really call a function that takes a Char[] by passing the chars as separate parameters?

    How does it deal with this:

    void func(Char[] foo); void func(Char a, Char b);

    ...

    func('a', 'b');

    No. I pretty sure you can't. Hence why it should be func(new char[]{....});

  • B Pappin (unregistered)

    Well, at least its easy to write a test and refactor all those method by method until your done. It could be worse.

  • diaphanein (unregistered) in reply to Tim
    Tim:
    I'm pretty sure this is C# code, not Java.

    I don't know C# - can you really call a function that takes a Char[] by passing the chars as separate parameters?

    How does it deal with this:

    void func(Char[] foo); void func(Char a, Char b);

    ...

    func('a', 'b');

    If foo is marked with "params", yes. It's C# implementation of variable length arguments. http://msdn.microsoft.com/en-us/library/w5zay9db.aspx

    Which overload called is dependent upon how its invoked. func('a', 'b') will call the second. func(new char[]{'a', 'b'}) with call the first.

  • A. Friend (unregistered) in reply to sagaciter (rocking the captchah, rocking the captchah...)
    sagaciter (rocking the captchah:
    - the a st**pid fail-training (...)
    Shouldn't that be st??pid, st*pid
  • (cs)

    Must be amateur hour on TDWTF.

    This is a rookie mistake, but also an understandable one. I'm going to guess the guy who wrote this came from a background full of languages with crap libraries, and so it didn't even occur to him that somebody might have solved his problem in advance.

    Now if this guy was an experienced C# (is that it?) dev, then yeah, it becomes a WTF, though not a colossal one.

    I was kind of hoping for this guy to be the Director of IT or something and mandate that all libraries have to be re-implemented internally because "Microsoft isn't any good."

Leave a comment on “The Complicator's Email Address Parser”

Log In or post as a guest

Replying to comment #:

« Return to Article