gosplitargs

package module
v0.0.0-...-cbd889c Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: ISC Imports: 1 Imported by: 8 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gosplitargs

Splits strings into tokens by given separator except treating quoted part as a single token.

#Installation go get -u github.com/elgs/gosplitargs

#Usage

package main

import (
	"fmt"
	"github.com/elgs/gosplitargs"
)

func main() {
	i1 := "I said 'I am sorry.', and he said \"it doesn't matter.\""
	o1, _ := gosplitargs.SplitArgs(i1, "\\s")
	for _, s := range o1 {
		fmt.Println(s)
	}
	/*
	   [ 'I',
	     'said',
	     'I am sorry.,',
	     'and',
	     'he',
	     'said',
	     'it doesn\'t matter.' ]
	*/

	i2 := "I said \"I am sorry.\", and he said \"it doesn't matter.\""
	o2, _ := gosplitargs.SplitArgs(i2, "\\s")
	for _, s := range o2 {
		fmt.Println(s)
	}
	/*
	   [ 'I',
	     'said',
	     'I am sorry.,',
	     'and',
	     'he',
	     'said',
	     'it doesn\'t matter.' ]
	*/

	i3 := `I said "I am sorry.", and he said "it doesn't matter."`
	o3, _ := gosplitargs.SplitArgs(i3, "\\s")
	for _, s := range o3 {
		fmt.Println(s)
	}
	/*
	   [ 'I',
	     'said',
	     'I am sorry.,',
	     'and',
	     'he',
	     'said',
	     'it doesn\'t matter.' ]
	*/

	i4 := `I said 'I am sorry.', and he said "it doesn't matter."`
	o4, _ := gosplitargs.SplitArgs(i4, "\\s")
	for _, s := range o4 {
		fmt.Println(s)
	}
	/*
	   [ 'I',
	     'said',
	     'I am sorry.,',
	     'and',
	     'he',
	     'said',
	     'it doesn\'t matter.' ]
	*/
}

Documentation

Overview

gosplitargs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitArgs

func SplitArgs(input string, separator string, keepQuotes bool) ([]string, error)

func SplitSQL

func SplitSQL(input string, separator string, keepQuotes bool) ([]string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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