in reply to Re^3: regex match only outside the double quotes
in thread regex match only outside the double quotes

In many cases the simple way is just fine. In fact I've done the same sort of thing just today; splitting a CSV file on commas because I happen to know that it is safe for my particular input.

But it is always good to be aware of the potential pitfalls so that you're not completely surprised when the bottom drops out because the input has changed or somebody typed a bad description.

  • Comment on Re^4: regex match only outside the double quotes

Replies are listed 'Best First'.
Re^5: regex match only outside the double quotes
by JavaFan (Canon) on Aug 21, 2009 at 22:58 UTC
    Problem is, if you willy-nilly assume the quotes can be escaped, and pick an escape character, you will be completely surprised if the quotes cannot be escaped, or are escaped differently than you expect.

    If things aren't specified, don't assume. Many bugs come from programmer assuming things they shouldn't have.