splitter

package module
v1.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2022 License: Apache-2.0 Imports: 3 Imported by: 12

README

Splitter

GoDoc Latest Version codecov Go Report Card

Overview

Go package for splitting strings (aware of enclosing braces and quotes)

The problem with standard Golang strings.Split is that it does not take into consideration that the string being split may contain enclosing braces and/or quotes (where the separator should not be considered where it's inside braces or quotes)

Take for example a string representing a slice of comma separated strings...

    str := `"aaa","bbb","this, for sanity, should not be split"`

running strings.Split on that...

package main

import "strings"

func main() {
    str := `"aaa","bbb","this, for sanity, should not be parts"`
    parts := strings.Split(str, `,`)
    println(len(parts))
}

would yield 5 (try on go-playground) - instead of the desired 3

However, with splitter, the result would be different...

package main

import "github.com/go-andiamo/splitter"

func main() {
    commaSplitter, _ := splitter.NewSplitter(',', splitter.DoubleQuotes)

    str := `"aaa","bbb","this, for sanity, should not be split"`
    parts, _ := commaSplitter.Split(str)
    println(len(parts))
}

which yields the desired 3! try on go-playground

Note: The varargs, after the first separator arg, are the desired 'enclosures' (e.g. quotes, brackets, etc.) to be taken into consideration

While splitting, any enclosures specified are checked for balancing!

Installation

To install Splitter, use go get:

go get github.com/go-andiamo/splitter

To update Splitter to the latest version, run:

go get -u github.com/go-andiamo/splitter

Enclosures

Enclosures instruct the splitter specific start/end sequences within which the separator is not to be considered. An enclosure can be one of two types: quotes or brackets.

Quote type enclosures only differ from bracket type enclosures in the way that their optional escaping works -

  • Quote enclosures can be:
    • escaped by escape prefix - e.g. a quote enclosure starting with " and ending with " but \" is not seen as ending
    • escaped by doubles - e.g. a quote enclosure starting with ' and ending with ' but any doubles '' are not seen as ending
  • Bracket enclosures can only be:
    • escaped by escape prefix - e.g. a bracket enclosure starting with ( and ending with ) and escape set to \
      • \( is not seen as a start
      • \) is not seen as an end

Note that brackets are ignored inside quotes - but quotes can exist within brackets. And when splitting, separators found within any specified quote or bracket enclosure are not considered.

The Splitter provides many pre-defined enclosures:

Var Name Type Start - End Escaped end
DoubleQuotes Quote " " none
DoubleQuotesBackSlashEscaped Quote " " \"
DoubleQuotesDoubleEscaped Quote " " ""
SingleQuotes Quote ' ' none
SingleQuotesBackSlashEscaped Quote ' ' \'
SingleQuotesDoubleEscaped Quote ' ' ''
SingleInvertedQuotes Quote ` ` none
SingleInvertedQuotesBackSlashEscaped Quote ` ` \'
SingleInvertedQuotesDoubleEscaped Quote ` ` ``
SinglePointingAngleQuotes Quote none
SinglePointingAngleQuotesBackSlashEscaped Quote \›
DoublePointingAngleQuotes Quote « » none
LeftRightDoubleDoubleQuotes Quote none
LeftRightDoubleSingleQuotes Quote none
LeftRightDoublePrimeQuotes Quote none
SingleLowHigh9Quotes Quote none
DoubleLowHigh9Quotes Quote none
Parenthesis Brackets ( ) none
CurlyBrackets Brackets { } none
SquareBrackets Brackets [ ] none
LtGtAngleBrackets Brackets < > none
LeftRightPointingAngleBrackets Brackets none
SubscriptParenthesis Brackets none
SuperscriptParenthesis Brackets none
SmallParenthesis Brackets none
SmallCurlyBrackets Brackets none
DoubleParenthesis Brackets none
MathWhiteSquareBrackets Brackets none
MathAngleBrackets Brackets none
MathDoubleAngleBrackets Brackets none
MathWhiteTortoiseShellBrackets Brackets none
MathFlattenedParenthesis Brackets none
OrnateParenthesis Brackets ﴿ none
AngleBrackets Brackets none
DoubleAngleBrackets Brackets none
FullWidthParenthesis Brackets none
FullWidthSquareBrackets Brackets none
FullWidthCurlyBrackets Brackets none
SubstitutionBrackets Brackets none
SubstitutionQuotes Quote none
DottedSubstitutionBrackets Brackets none
DottedSubstitutionQuotes Quote none
TranspositionBrackets Brackets none
TranspositionQuotes Quote none
RaisedOmissionBrackets Brackets none
RaisedOmissionQuotes Quote none
LowParaphraseBrackets Brackets none
LowParaphraseQuotes Quote none
SquareWithQuillBrackets Brackets none
WhiteParenthesis Brackets none
WhiteCurlyBrackets Brackets none
WhiteSquareBrackets Brackets none
WhiteLenticularBrackets Brackets none
WhiteTortoiseShellBrackets Brackets none
FullWidthWhiteParenthesis Brackets none
BlackTortoiseShellBrackets Brackets none
BlackLenticularBrackets Brackets none
PointingCurvedAngleBrackets Brackets none
TortoiseShellBrackets Brackets none
SmallTortoiseShellBrackets Brackets none
ZNotationImageBrackets Brackets none
ZNotationBindingBrackets Brackets none
MediumOrnamentalParenthesis Brackets none
LightOrnamentalTortoiseShellBrackets Brackets none
MediumOrnamentalFlattenedParenthesis Brackets none
MediumOrnamentalPointingAngleBrackets Brackets none
MediumOrnamentalCurlyBrackets Brackets none
HeavyOrnamentalPointingAngleQuotes Quote none
HeavyOrnamentalPointingAngleBrackets Brackets none

Note: To convert any of the above enclosures to escaping - use the MakeEscapable() or MustMakeEscapable() functions.

Quote enclosures with escaping

Quotes within quotes can be handled by using an enclosure that specifies how the escaping works, for example the following uses \ (backslash) prefixed escaping...

package main

import "github.com/go-andiamo/splitter"

func main() {
    commaSplitter, _ := splitter.NewSplitter(',', splitter.DoubleQuotesBackSlashEscaped)

    str := `"aaa","bbb","this, for sanity, \"should\" not be split"`
    parts, _ := commaSplitter.Split(str)
    println(len(parts))
}

try on go-playground

Or with double escaping...

package main

import "github.com/go-andiamo/splitter"

func main() {
    commaSplitter, _ := splitter.NewSplitter(',', splitter.DoubleQuotesDoubleEscaped)

    str := `"aaa","bbb","this, for sanity, """"should,,,,"" not be split"`
    parts, _ := commaSplitter.Split(str)
    println(len(parts))
}

try on go-playground

Not separating when separator encountered in quotes or brackets...
package main

import (
    "fmt"
    "github.com/go-andiamo/splitter"
)

func main() {
    encs := []*splitter.Enclosure{
        splitter.Parenthesis, splitter.SquareBrackets, splitter.CurlyBrackets,
        splitter.DoubleQuotesDoubleEscaped, splitter.SingleQuotesDoubleEscaped,
    }
    commaSplitter, _ := splitter.NewSplitter(',', encs...)

    str := `do(not,)split,'don''t,split,this',[,{,(a,"this has "" quotes")}]`
    parts, _ := commaSplitter.Split(str)
    println(len(parts))
    for i, pt := range parts {
        fmt.Printf("\t[%d]%s\n", i, pt)
    }
}

try on go-playground

Options

Options define behaviours that are to be carried out on each found part during splitting.

An option, by virtue of it's return args from .Apply(), can do one of three things:

  1. return a modified string of what is to be added to the split parts
  2. return a false to indicate that the split part is not to be added to the split result
  3. return an error to indicate that the split part is unacceptable (and cease further splitting - the error is returned from the Split method)

Options can be added directly to the Splitter using .AddDefaultOptions() method. These options are checked for every call to the splitters .Split() method.

Options can also be specified when calling the splitter .Split() method - these options are only carried out for this call (and after any options already specified on the splitter)

Option Examples
1. Stripping empty parts
package main

import (
    "fmt"
    "github.com/go-andiamo/splitter"
)

func main() {
    s := splitter.MustCreateSplitter('/').
        AddDefaultOptions(splitter.IgnoreEmpties)

    parts, _ := s.Split(`/a//c/`)
    println(len(parts))
    fmt.Printf("%+v", parts)
}

try on go-playground

2. Stripping empty first/last parts
package main

import (
    "fmt"
    "github.com/go-andiamo/splitter"
)

func main() {
    s := splitter.MustCreateSplitter('/').
        AddDefaultOptions(splitter.IgnoreEmptyFirst, splitter.IgnoreEmptyLast)

    parts, _ := s.Split(`/a//c/`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)

    parts, _ = s.Split(`a//c/`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)

    parts, _ = s.Split(`/a//c`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)
}

try on go-playground

3. Trimming parts
package main

import (
    "fmt"
    "github.com/go-andiamo/splitter"
)

func main() {
    s := splitter.MustCreateSplitter('/').
        AddDefaultOptions(splitter.TrimSpaces)

    parts, _ := s.Split(`/a/b/c/`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)

    parts, _ = s.Split(`  / a /b / c/    `)
    println(len(parts))
    fmt.Printf("%+v\n", parts)

    parts, _ = s.Split(`/   a   /   b   /   c   /`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)
}

try on go-playground

4. Trimming spaces (and removing empties)
package main

import (
    "fmt"
    "github.com/go-andiamo/splitter"
)

func main() {
    s := splitter.MustCreateSplitter('/').
        AddDefaultOptions(splitter.TrimSpaces, splitter.IgnoreEmpties)

    parts, _ := s.Split(`/a/  /c/`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)

    parts, _ = s.Split(`  / a // c/    `)
    println(len(parts))
    fmt.Printf("%+v\n", parts)

    parts, _ = s.Split(`/   a   /      /   c   /`)
    println(len(parts))
    fmt.Printf("%+v\n", parts)
}

try on go-playground

5. Error for empties found
package main

import (
    "fmt"
    "github.com/go-andiamo/splitter"
)

func main() {
    s := splitter.MustCreateSplitter('/').
        AddDefaultOptions(splitter.TrimSpaces, splitter.NoEmpties)

    if parts, err := s.Split(`/a/  /c/`); err != nil {
        println(err.Error())
    } else {
        println(len(parts))
        fmt.Printf("%+v\n", parts)
    }

    if parts, err := s.Split(`  / a // c/    `); err != nil {
        println(err.Error())
    } else {
        println(len(parts))
        fmt.Printf("%+v\n", parts)
    }

    if parts, err := s.Split(`/   a   /      /   c   /`); err != nil {
        println(err.Error())
    } else {
        println(len(parts))
        fmt.Printf("%+v\n", parts)
    }

    if parts, err := s.Split(` a / b/c `); err != nil {
        println(err.Error())
    } else {
        println(len(parts))
        fmt.Printf("%+v\n", parts)
    }
}

try on go-playground

Documentation

Overview

Package splitter - Go package for splitting strings (aware of enclosing braces and quotes)

The problem with strings.Split is that it does not take into consideration that the string being split may contain enclosing braces and/or quotes (where the separator should not be considered where it's inside braces or quotes)

Take for example a string representing a slice of comma separated strings...

str := `"aaa","bbb","this, for sanity, should not be split"`

running strings.Split on that...

str := `"aaa","bbb","this, for sanity, should not be split"`
parts := strings.Split(str, `,`)
println(len(parts))

would yield 5 - instead of the desired 3

With splitter, the result would be different...

str := `"aaa","bbb","this, for sanity, should not be split"`
mySplitter, _ := splitter.NewSplitter(',', splitter.DoubleQuotes)
parts, _ := mySplitter.Split(str)
println(len(parts))

which yields the desired 3!

Note: The varargs, after the first separator arg, are the desired 'enclosures' (e.g. quotes, brackets, etc.) to be taken into consideration

While splitting, any enclosures specified are checked for balancing!

Index

Constants

This section is empty.

Variables

View Source
var (
	DoubleQuotes                              = _DoubleQuotes
	DoubleQuotesBackSlashEscaped              = MustMakeEscapable(_DoubleQuotes, escBackslash)
	DoubleQuotesDoubleEscaped                 = MustMakeEscapable(_DoubleQuotes, '"')
	SingleQuotes                              = _SingleQuotes
	SingleQuotesBackSlashEscaped              = MustMakeEscapable(_SingleQuotes, escBackslash)
	SingleQuotesDoubleEscaped                 = MustMakeEscapable(_SingleQuotes, '\'')
	SingleInvertedQuotes                      = _SingleInvertedQuotes
	SingleInvertedQuotesBackSlashEscaped      = MustMakeEscapable(_SingleInvertedQuotes, escBackslash)
	SingleInvertedQuotesDoubleEscaped         = MustMakeEscapable(_SingleInvertedQuotes, '`')
	DoublePointingAngleQuotes                 = _DoublePointingAngleQuotes
	SinglePointingAngleQuotes                 = _SinglePointingAngleQuotes
	SinglePointingAngleQuotesBackSlashEscaped = MustMakeEscapable(_SinglePointingAngleQuotes, escBackslash)
	LeftRightDoubleDoubleQuotes               = _LeftRightDoubleDoubleQuotes
	LeftRightDoubleSingleQuotes               = _LeftRightDoubleSingleQuotes
	LeftRightDoublePrimeQuotes                = _LeftRightDoublePrimeQuotes
	SingleLowHigh9Quotes                      = _SingleLowHigh9Quotes
	DoubleLowHigh9Quotes                      = _DoubleLowHigh9Quotes
	Parenthesis                               = _Parenthesis
	CurlyBrackets                             = _CurlyBrackets
	SquareBrackets                            = _SquareBrackets
	LtGtAngleBrackets                         = _LtGtAngleBrackets
	LeftRightPointingAngleBrackets            = _LeftRightPointingAngleBrackets
	SubscriptParenthesis                      = _SubscriptParenthesis
	SuperscriptParenthesis                    = _SuperscriptParenthesis
	SmallParenthesis                          = _SmallParenthesis
	SmallCurlyBrackets                        = _SmallCurlyBrackets
	DoubleParenthesis                         = _DoubleParenthesis
	MathWhiteSquareBrackets                   = _MathWhiteSquareBrackets
	MathAngleBrackets                         = _MathAngleBrackets
	MathDoubleAngleBrackets                   = _MathDoubleAngleBrackets
	MathWhiteTortoiseShellBrackets            = _MathWhiteTortoiseShellBrackets
	MathFlattenedParenthesis                  = _MathFlattenedParenthesis
	OrnateParenthesis                         = _OrnateParenthesis
	AngleBrackets                             = _AngleBrackets
	DoubleAngleBrackets                       = _DoubleAngleBrackets
	FullWidthParenthesis                      = _FullWidthParenthesis
	FullWidthSquareBrackets                   = _FullWidthSquareBrackets
	FullWidthCurlyBrackets                    = _FullWidthCurlyBrackets
	SubstitutionBrackets                      = _SubstitutionBrackets
	SubstitutionQuotes                        = _SubstitutionQuotes
	DottedSubstitutionBrackets                = _DottedSubstitutionBrackets
	DottedSubstitutionQuotes                  = _DottedSubstitutionQuotes
	TranspositionBrackets                     = _TranspositionBrackets
	TranspositionQuotes                       = _TranspositionQuotes
	RaisedOmissionBrackets                    = _RaisedOmissionBrackets
	RaisedOmissionQuotes                      = _RaisedOmissionQuotes
	LowParaphraseBrackets                     = _LowParaphraseBrackets
	LowParaphraseQuotes                       = _LowParaphraseQuotes
	SquareWithQuillBrackets                   = _SquareWithQuillBrackets
	WhiteParenthesis                          = _WhiteParenthesis
	WhiteCurlyBrackets                        = _WhiteCurlyBrackets
	WhiteSquareBrackets                       = _WhiteSquareBrackets
	WhiteLenticularBrackets                   = _WhiteLenticularBrackets
	WhiteTortoiseShellBrackets                = _WhiteTortoiseShellBrackets
	FullWidthWhiteParenthesis                 = _FullWidthWhiteParenthesis
	BlackTortoiseShellBrackets                = _BlackTortoiseShellBrackets
	BlackLenticularBrackets                   = _BlackLenticularBrackets
	PointingCurvedAngleBrackets               = _PointingCurvedAngleBrackets
	TortoiseShellBrackets                     = _TortoiseShellBrackets
	SmallTortoiseShellBrackets                = _SmallTortoiseShellBrackets
	ZNotationImageBrackets                    = _ZNotationImageBrackets
	ZNotationBindingBrackets                  = _ZNotationBindingBrackets
	MediumOrnamentalParenthesis               = _MediumOrnamentalParenthesis
	LightOrnamentalTortoiseShellBrackets      = _LightOrnamentalTortoiseShellBrackets
	MediumOrnamentalFlattenedParenthesis      = _MediumOrnamentalFlattenedParenthesis
	MediumOrnamentalPointingAngleBrackets     = _MediumOrnamentalPointingAngleBrackets
	MediumOrnamentalCurlyBrackets             = _MediumOrnamentalCurlyBrackets
	HeavyOrnamentalPointingAngleQuotes        = _HeavyOrnamentalPointingAngleQuotes
	HeavyOrnamentalPointingAngleBrackets      = _HeavyOrnamentalPointingAngleBrackets
)
View Source
var (
	TrimSpaces            Option = _TrimSpaces            // TrimSpaces causes split parts to be trimmed of leading & trailing spaces
	Trim                         = _Trim                  // Trim causes split parts to be trimmed of the leading & trailing custsets specified
	NoEmpties             Option = _NoEmpties             // NoEmpties causes an error if a split part is empty
	NoEmptiesMsg                 = _NoEmptiesMsg          // NoEmptiesMsg is the same as NoEmpties but allows a custom error message
	IgnoreEmpties         Option = _IgnoreEmpties         // IgnoreEmpties causes empty split parts to not be added to the result
	NotEmptyFirst         Option = _NotEmptyFirst         // NotEmptyFirst causes an error if the first split part is empty
	NotEmptyFirstMsg             = _NotEmptyFirstMsg      // NotEmptyFirstMsg is the same as NotEmptyFirst but allows a custom error message
	IgnoreEmptyFirst      Option = _IgnoreEmptyFirst      // IgnoreEmptyFirst causes an empty first split part not to be added to the result
	NotEmptyLast          Option = _NotEmptyLast          // NotEmptyLast causes an error if the last split part is empty
	NotEmptyLastMsg              = _NotEmptyLastMsg       // NotEmptyLastMsg is the same as NotEmptyLast but allows a custom error message
	IgnoreEmptyLast       Option = _IgnoreEmptyLast       // IgnoreEmptyLast causes an empty last split part not to be added to the result
	NotEmptyInners        Option = _NotEmptyInners        // NotEmptyInners causes an error if an inner (i.e. not first or last) split part is empty
	NotEmptyInnersMsg            = _NotEmptyInnersMsg     // NotEmptyInnersMsg is the same as NotEmptyInners but allows a custom error message
	IgnoreEmptyInners     Option = _IgnoreEmptyInners     // IgnoreEmptyInners causes empty inner (i.e. not first or last) split parts not to be added to the result
	NotEmptyOuters        Option = _NotEmptyOuters        // NotEmptyOuters causes an error if an outer (i.e. first or last) split part is empty (same as adding both NotEmptyFirst & NotEmptyLast)
	NotEmptyOutersMsg            = _NotEmptyOutersMsg     // NotEmptyOutersMsg is the same as NotEmptyOuters but allows a custom error message
	IgnoreEmptyOuters     Option = _IgnoreEmptyOuters     // IgnoreEmptyOuters causes empty outer (i.e. first or last) split parts not to be added to the result (same as adding both IgnoreEmptyFirst & IgnoreEmptyLast)
	NoContiguousQuotes    Option = _NoContiguousQuotes    // NoContiguousQuotes causes an error if there are contiguous quotes within a split part
	NoContiguousQuotesMsg        = _NoContiguousQuotesMsg // NoContiguousQuotesMsg is the same as NoContiguousQuotes but allows a custom error message
	NoMultiQuotes         Option = _NoMultiQuotes         // NoMultiQuotes causes an error if there are multiple (not necessarily contiguous) quotes within a split part
	NoMultiQuotesMsg             = _NoMultiQuotesMsg      // NoMultiQuotesMsg is the same as NoMultiQuotes but allows a custom error message
	NoMultis              Option = _NoMultis              // NoMultis causes an error if there are multiple quotes or brackets in a split part
	NoMultisMsg                  = _NoMultisMsg           // NoMultisMsg is the same as NoMultis but allows a custom error message
	StripQuotes           Option = _StripQuotes           // StripQuotes causes quotes within a split part to be stripped
	UnescapeQuotes        Option = _UnescapeQuotes        // UnescapeQuotes causes any quotes within the split part to have any escaped end quotes to be removed
)

Functions

This section is empty.

Types

type Enclosure

type Enclosure struct {
	// the starting rune for the enclosure
	Start rune
	// the ending rune for the enclosure
	End rune
	// whether the enclosure is a quote enclosure
	IsQuote bool
	// whether the close is escapable (only for IsQuote)
	Escapable bool
	// the prefix escape rune (only for IsQuote & and used with Escapable)
	Escape rune
}

Enclosure is used when creating a splitter to denote what 'enclosures' (e.g. quotes or brackets) are to be considered when slitting.

For example, creating a NewSplitter with separator of ',' (comma) and an Enclosure with Start and End of `"` (double quotes) - splitting the following...

str := `"aaa","dont,split,this"`

would yield two split items - `"aaa"` and `"dont,split,this"`

func MakeEscapable added in v1.2.5

func MakeEscapable(enc *Enclosure, esc rune) (*Enclosure, error)

MakeEscapable makes an escapable copy of an enclosure

returns an error if the supplied Enclosure is a brackets and the escape rune matches either the start or end rune (because brackets cannot be double-escaped - as this would prevent nested brackets)

func MustMakeEscapable added in v1.2.5

func MustMakeEscapable(enc *Enclosure, esc rune) *Enclosure

MustMakeEscapable is the same as MakeEscapable, except that it panics on error

type Option added in v1.2.0

type Option interface {
	Apply(s string, pos int, totalLen int, captured int, skipped int, isLast bool, subParts ...SubPart) (string, bool, error)
}

type Splitter

type Splitter interface {
	// Split performs a split on the supplied string - returns the split parts and any error encountered
	//
	// If an error is returned, it will always be of type splittingError
	Split(s string, options ...Option) ([]string, error)
	// AddDefaultOptions adds default options for the splitter (other options can also be added when using Split)
	AddDefaultOptions(options ...Option) Splitter
}

Splitter is the actual splitter interface

func MustCreateSplitter

func MustCreateSplitter(separator rune, encs ...*Enclosure) Splitter

MustCreateSplitter is the same as NewSplitter, except that it panics in case of error

func NewSplitter

func NewSplitter(separator rune, encs ...*Enclosure) (Splitter, error)

NewSplitter creates a new splitter

the `separator` arg is the rune on which to split

the optional `encs` varargs are the enclosures (e.g. brackets, quotes) to be taken into consideration when splitting

An error is returned if any of enclosures specified match any other enclosure `Start`/`End`

type SplittingError added in v1.1.0

type SplittingError interface {
	error
	Type() SplittingErrorType
	Position() int
	Rune() rune
	Enclosure() *Enclosure
	Wrapped() error
	Unwrap() error
}

SplittingError is the error type always returned from Splitter.Split

func NewOptionFailError added in v1.2.0

func NewOptionFailError(msg string, pos int, subPart SubPart) SplittingError

type SplittingErrorType added in v1.1.0

type SplittingErrorType int

SplittingErrorType is the splitting error type - as used by splittingError

const (
	Unopened SplittingErrorType = iota
	Unclosed
	OptionFail
	Wrapped
)

type SubPart added in v1.1.0

type SubPart interface {
	// StartPos returns the start position (relative to the original string) of the part
	StartPos() int
	// EndPos returns the end position (relative to the original string) of the part
	EndPos() int
	// IsQuote returns whether the part is quotes enclosure
	IsQuote() bool
	// IsBrackets returns whether the part is a brackets enclosure
	IsBrackets() bool
	// IsFixed returns whether the part was fixed text (i.e not quotes or brackets)
	IsFixed() bool
	// Type returns the part type (fixed, quotes, brackets)
	Type() SubPartType
	// Escapable returns whether the original enclosure was escapable
	Escapable() bool
	// StartRune returns the start rune of the enclosure
	StartRune() rune
	// EndRune returns the end rune of the enclosure
	EndRune() rune
	// EscapeRune returns the original escape rune for the enclosure
	EscapeRune() rune
	// UnEscaped returns the unescaped string
	//
	// If the part was a quote enclosure, the enclosing quote marks are stripped and, if escapable, any escaped quotes are transposed.
	// If the quote enclosure was not escapable, just the enclosing quote marks are removed
	//
	// If the part was not a quote enclosure, the original string part is returned
	UnEscaped() string
	// String returns the actual raw string of the part
	String() string
	// IsWhitespaceOnly returns whether the item is whitespace only (using the given trim cutset)
	IsWhitespaceOnly(cutset ...string) bool

	Enclosure() *Enclosure
}

SubPart is the interfaces passed to Options.Apply - to enable examination of sub-parts found in a split part

type SubPartType added in v1.1.0

type SubPartType int

SubPartType denotes the type of the SubPart (as returned from SubPart.Type)

const (
	Fixed SubPartType = iota
	Quotes
	Brackets
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL