Documentation ¶
Overview ¶
Package qsplit (short for "quoted split") performs a Unix shell style split-on-whitespace of its input. Its functions return the non-whitespace "chunks" contained in their input, treating text within balanced quotes as a single chunk.
Whitespace, according to qsplit, is the ASCII space and horizontal tab characters.
By default, qsplit is aware only of the ASCII single and double quote characters as chunk delineators. This can be changed with `SetQuotes`.
These are the rules used to delineate quoted chunks:
- Quotes begin only at a word boundary
- Quotes extend to the first closing quotation mark which matches the opening quote, which may or may not be at a word boundary.
- Quotes do not nest
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LocationsOnce ¶
LocationsOnce returns the beginning and end point of the first chunk, and the beginning of the next chunk. If this is all you need, LocationsOnce is significantly faster than Locations.
If no chunks are found, the 1st element of the returned array will be -1. If only one chunk is found, the 3rd element will be -1.
func Once ¶
Once performs a single quoted split, returning the first chunk found in the input byteslice, and the remainder of the byteslice
func SetQuotes ¶ added in v2.4.0
func SetQuotes(qopen, qclose []rune)
SetQuotes sets the list of runes which will be considered quote-open and quote-close characters. As an example, to emulate the behavior of old versions of qsplit, the call would be:
SetQuotes([]rune{'\'', '"', '`', '‹', '«', '「', '『'}, []rune{'\'', '"', '`', '›', '»', '」', '』'})
func ToStringBytes ¶
ToStringBytes performs a quoted split, returning the first chunk as a string and the rest as a slice of byteslices.
Types ¶
This section is empty.