collapsewhitespace

package module
v0.0.0-...-23971e8 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: MIT Imports: 2 Imported by: 0

README

collapsewhitespace

Build Status Go Report Card Go docs

Efficiently collapse multiple whitespace characters in a string into a single space.

Usage

import "4d63.com/collapsewhitespace"
collapsewhitespace.String("a  b	\nc") // "a b c"

Documentation

Overview

Package collapsewhitespace contains a function that collapses whitespace between characters (runes) in a string such that all non-whitespace is only separated by at most one space character.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String(s string) string

String collapses any whitespace that is not a single standalone space, into a single space.

Whitespace is:

'\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP).
Example
package main

import (
	"fmt"

	"4d63.com/collapsewhitespace"
)

func main() {
	s := collapsewhitespace.String("abc def			\nghi")

	fmt.Print(s)

}
Output:

abc def ghi

Types

This section is empty.

Jump to

Keyboard shortcuts

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