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
      Output:
      
      abc def ghi
      

      Types

      This section is empty.