Building a regexp to split a string
        Posted  
        
            by Kivin
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Kivin
        
        
        
        Published on 2010-03-17T03:27:01Z
        Indexed on 
            2010/03/17
            3:31 UTC
        
        
        Read the original article
        Hit count: 408
        
I'm seeking a solution to splitting a string which contains text in the following format:
"abcd efgh 'ijklm no pqrs' tuv"
which will produce the following results:
['abcd', 'efgh', 'ijklm no pqrs', 'tuv']
In otherwords, it splits by whitespace unless inside of a single quoted string. I think it could be done with .NET regexps using "Lookaround" operators, particularly balancing operators. I'm not so sure about perl.
© Stack Overflow or respective owner