in reply to Re: To regex or not to regex
in thread To regex or not to regex

This code is slightly broken because it ignores a requirement that was specified by the problem (every section starts with a line containing a number which is the number of records) and relies on an assumption instead (every section is terminated by ==== followed by "\n"). There are at least three cases where this would break, and they do happen more often than not. So, the wisdom behind this story: follow the specs carefully and don't golf when you don't need to.

Hope this helps,,,

Aziz,,,

Replies are listed 'Best First'.
Re: Re: Re: To regex or not to regex
by mndoci (Scribe) on Mar 11, 2002 at 07:11 UTC
    Yes it does rely on that assumption. I did have lines in my code that removed leading whitespace, but I didn't think about trailing whitespace. As for records between the # and '====', they will nto have any '====', so I guess I am safe, but I agree, my solution is not general. Thanks for the warning!!

    mndoci

    "What you do in this world is a matter of no consequence. The question is, what can you make people believe that you have done?"-Sherlock Holmes in 'A study in scarlet'

Re: Re: Re: To regex or not to regex
by mndoci (Scribe) on Mar 11, 2002 at 07:14 UTC
    Just realized that your post was targeted at Anonymous' post and not mine. DUH!!!!
    That said, I almost used '====' as the separator, but my first test went into a weird loop, so I did not continue along that path.

    mndoci

    "What you do in this world is a matter of no consequence. The question is, what can you make people believe that you have done?"-Sherlock Holmes in 'A study in scarlet'