// stripWhitespace strips whitespace from both ends of a string, but only up to
// margin on the left hand side.  E.g., stripWhitespace("  foo ", 1) == " foo".
518450
func stripWhitespace(s string, margin int) string {
	runes := []rune(s)
	if len(s) == 0 {
		return s // Avoid underflow below.
	}
	i := 0
	for i < len(runes) && isHorizontalWhitespace(runes[i]) && i < margin {
		i++
	}
	j := len(runes)
	for j > i && isHorizontalWhitespace(runes[j-1]) {
		j--
	}
	return string(runes[i:j])
}
1255137
func skipWhitespace(buf []byte, i int) int {
	for i < len(buf) {
		if buf[i] != ' ' && buf[i] != '\t' && buf[i] != 0 {
			break
		}
		i++
	}
	return i
}
839723
func containsSpace(s string) bool {
	for _, c := range s {
		if c == ' ' {
			return true
		}
	}
	return false
}
886176
func StripTags(src string) string {
	//将HTML标签全转换成小写
	//src = regexpAnyHTMLTag.ReplaceAllStringFunc(src, strings.ToLower)

	//remove tag <style>
	src = regexpStyleHTMLTag.ReplaceAllString(src, "")

	//remove tag <script>
	src = regexpScriptHTMLTag.ReplaceAllString(src, "")

	//replace all html tag into \n
	src = regexpAnyHTMLTag.ReplaceAllString(src, "\n")

	//trim all spaces(2+) into \n
	src = regexpMoreSpace.ReplaceAllString(src, "\n")

	return strings.TrimSpace(src)
}
77191
func (s *Scanner) peekIgnoreWhitespace() rune {
	var b []byte
	if s.i < len(s.b) {
		b = s.b[s.i:]
	}

	for i := 0; ; i++ {
		if len(b) == 0 {
			return eof
		}

		ch, sz := utf8.DecodeRune(b)
		if !isWhitespace(ch) {
			return ch
		}

		b = b[sz:]
	}
}
1074033
func StripTags(src string) string {
	//去除style,script,html tag
	re := regexp.MustCompile(`(?s)<(?:style|script)[^<>]*>.*?</(?:style|script)>|</?[a-z][a-z0-9]*[^<>]*>|<!--.*?-->`)
	src = re.ReplaceAllString(src, "")

	//trim all spaces(2+) into \n
	re = regexp.MustCompile(`\s{2,}`)
	src = re.ReplaceAllString(src, "\n")

	return strings.TrimSpace(src)
}
41577
func stripExcessSpaces(vals []string) {
	var j, k, l, m, spaces int
	for i, str := range vals {
		// Trim trailing spaces
		for j = len(str) - 1; j >= 0 && str[j] == ' '; j-- {
		}

		// Trim leading spaces
		for k = 0; k < j && str[k] == ' '; k++ {
		}
		str = str[k : j+1]

		// Strip multiple spaces.
		j = strings.Index(str, doubleSpace)
		if j < 0 {
			vals[i] = str
			continue
		}

		buf := []byte(str)
		for k, m, l = j, j, len(buf); k < l; k++ {
			if buf[k] == ' ' {
				if spaces == 0 {
					// First space.
					buf[m] = buf[k]
					m++
				}
				spaces++
			} else {
				// End of multiple spaces.
				spaces = 0
				buf[m] = buf[k]
				m++
			}
		}

		vals[i] = string(buf[:m])
	}
}
428916
func rsplitspace(s string, max int) []string {
	res := make([]string, 0, max+1)
	end := -1 // index of field end, or -1 in a region of spaces.
	for i := len(s); i > 0; {
		r, sz := utf8.DecodeLastRuneInString(s[:i])
		if unicode.IsSpace(r) {
			if end >= 0 {
				if len(res) == max {
					break // let this field run to the start
				}
				res = append(res, s[i:end])
				end = -1
			}
		} else if end < 0 {
			end = i
		}
		i -= sz
	}
	if end >= 0 {
		res = append(res, s[:end])
	}

	resLen := len(res)
	for i := 0; i < resLen/2; i++ {
		res[i], res[resLen-1-i] = res[resLen-1-i], res[i]
	}

	return res
}
261197
func Wrappable(in string) string {
	buf := bytes.NewBuffer(nil)
	for _, ch := range in {
		buf.WriteRune(ch)
		if ch == ',' || ch == ')' {
			// zero-width whitespace
			buf.WriteRune('\u200B')
		}
	}
	return buf.String()
}
1186328
func StripPrefix(strip bool) source.Option {
	return func(o *source.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}

		o.Context = context.WithValue(o.Context, stripPrefixKey{}, strip)
	}
}
583559
func (s *Scanner) scanWhitespace() (tok Token, pos Pos, lit string) {
	// Create a buffer and read the current character into it.
	var buf bytes.Buffer
	ch, pos := s.r.curr()
	_, _ = buf.WriteRune(ch)

	// Read every subsequent whitespace character into the buffer.
	// Non-whitespace characters and EOF will cause the loop to exit.
	for {
		ch, _ = s.r.read()
		if ch == eof {
			break
		} else if !isWhitespace(ch) {
			s.r.unread()
			break
		} else {
			_, _ = buf.WriteRune(ch)
		}
	}

	return WS, pos, buf.String()
}
1130160
func (l *Lexer) consumeWhitespace() bool {
	c := l.r.Peek(0)
	if c == ' ' || c == '\t' || c == '\v' || c == '\f' {
		l.r.Move(1)
		return true
	} else if c >= 0xC0 {
		if r, n := l.r.PeekRune(0); r == '\u00A0' || r == '\uFEFF' || unicode.Is(unicode.Zs, r) {
			l.r.Move(n)
			return true
		}
	}
	return false
}
5315
func TrimSpace(str cty.Value) (cty.Value, error) {
	return TrimSpaceFunc.Call([]cty.Value{str})
}
998533
func stripEmptyDimensions(dims []string) []string {
	source := strpair.ParseMap(dims)
	result := strpair.Map{}
	for k, ds := range source {
		for _, dim := range ds {
			if dim != "" {
				result.Add(k, dim)
			}
		}
	}
	return result.Format()
}
1210720
func (pctx *parseCtx) skipWhiteSpaces() {
	for {
		switch t := pctx.peek(); t.Type {
		case SPACE, COMMENT_IDENT:
			pctx.advance()
			continue
		default:
			return
		}
	}
}
437228
func ReadWhitespace(r *bufio.Reader) {
	c, e := peek(r)
	for e != io.EOF && isWhitespace(c) {
		r.ReadByte()
		c, e = peek(r)
	}
}
162016
func SplitWhite(s string) ([]string, error) {
	reg, err := regexp.Compile("[ \t]+")
	if err != nil {
		return nil, err
	}
	s = reg.ReplaceAllString(s, " ")
	return strings.Split(s, " "), nil
}