go-chatwords

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT

README

go-chatwords

go.dev Build Status codecov Go Report Card GitHub last commit License

Parse line as chat words.

This package is inspired to github.com/mattn/go-shellwords.

Motivation

To develop a chat bot, it is useful to split a string into substrings. There are many awesome packages for cli tool, but it is out of scope for many of them to split a string into substrings. And some existing packages are made for shell, so they are inapropriate for the chat bot in terms of treat of special characters.

Usage

// ["<UXXXXX>", "echo", "hello world"], ""
args, text := chatwords.Split("<UXXXXX> echo 'hello world'", -1)
// ["<UXXXXX>", "echo"], " 'hello world'"
args, text := chatwords.Split("<UXXXXX> echo 'hello world'", 2)

The test code is also useful to understand this package's behavior.

Rules to split

special characters
  • quote: ', "
  • space: , \t
  • escape: \\

This package is not for shell, so the number of special characters is very small.

License

MIT

Directories

Path Synopsis
Package chatwords splits a string into substrings
Package chatwords splits a string into substrings

Jump to

Keyboard shortcuts

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