in reply to Re^2: Parsing a line of text items
in thread Parsing a line of text items

I would tend to agree that an approach using a reliable, common module like Text::ParseWords (of which I had not previously been aware -- thanks, philipbailey++) or Text::CSV is usually best. But I wanted to give an example of a "pure" regex approach.

As an aside, I think it's worth emphasizing again that whatever approach is taken, a thorough suite of tests for the final code is advisable even if the approach is based on well-tested modules.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: Parsing a line of text items
by LanX (Saint) on Apr 01, 2021 at 10:08 UTC
    This might sound strange, but these are human interfaces which are hard to test from some level of complexity on.

    I'm sure there are plenty of incompatible solutions, but nobody would notice they are different.

    For instance, what about single quotes without closing partner? Or quotes without neighboring whitespace?

    Do users even expect them to be parsed in a meaningful way?

    The behavior may differ between different solutions, while all are conceived correct.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery