// SplitFullName splits a name and returns the firstname, lastname
457
func SplitFullName(fullName string) (string, string) {
	nameComponents := strings.Split(fullName, " ")
	firstName := nameComponents[0]
	lastName := ""
	if len(nameComponents) > 1 {
		lastName = strings.Join(nameComponents[1:], " ")
	}
	return firstName, lastName
}
759848
func Name(name string) (should string) {
	should = lint.Name(name)

	for _, replace := range []struct {
		re *regexp.Regexp
		to string
	}{
		{re: reIDs, to: "IDs"},
		{re: reURLs, to: "URLs"},
		{re: reIDRef, to: "IDRef"},
	} {
		should = replace.re.ReplaceAllString(should, fmt.Sprintf("${1}%s${2}", replace.to))
	}

	return should
}
875746
func (l *Logger) normalizeName() {
	length := len(l.Name)

	// name is ok as it is
	if length == maxnamelen || length == curnamelen {
		return
	}

	// name is too short, add some spaces
	if length < curnamelen {
		l.normalizeNameLen()
		return
	}

	// name is too long
	// do best to normalize it

	var (
		normalized string
		parts      []string
		separator  byte
	)

	// try split long name using different separators
	// this first one which can split name into smaller parts will be used
	for _, sep := range separators {
		parts = strings.Split(l.Name, string(sep))
		if len(parts) > 1 {
			separator = sep
			break
		}
	}

	// if we sucesufully splitted string into multiple parts
	if len(parts) > 1 {
		appendSeparator := true

		for i, str := range parts {
			// if part length is bigger than zero
			switch len(str) {
			case 0:
				appendSeparator = false
				break
			case 1:
				normalized += str[:1]
				break
			case 2:
				normalized += str[:2]
				break
			default:
				normalized += str[:3]
				break
			}

			if appendSeparator && (i != (len(parts) - 1)) {
				normalized += string(separator)
			}
		}

		// if still to long
		if len(normalized) > maxnamelen {
			normalized = normalized[:maxnamelen]
		}
	} else {
		length := len(l.Name)
		if length > maxnamelen {
			normalized = l.Name[:maxnamelen]
		} else {
			normalized = l.Name[0:length]
		}
	}

	l.Name = normalized
	if len(normalized) >= curnamelen {
		curnamelen = len(normalized)
	} else {
		l.normalizeNameLen()
	}
}
74054
func ExpandTLFName(name string, finalizeInfo *ConversationFinalizeInfo) string {
	if finalizeInfo == nil {
		return name
	}
	if len(finalizeInfo.ResetFull) == 0 {
		return name
	}
	if strings.Contains(name, " account reset ") {
		return name
	}
	return name + " " + finalizeInfo.ResetFull
}
1169264
func SplitExtension(name string) (
	assertions, extensionSuffix string, err error) {
	names := strings.SplitN(name, HandleExtensionSep, 2)
	if len(names) > 2 {
		return "", "", BadNameError{name}
	}
	if len(names) > 1 {
		extensionSuffix = names[1]
	}
	return names[0], extensionSuffix, nil
}
1220190
func (p profile) fullname() string {
	fname := strings.TrimSpace(p.FirstName + " " + p.LastName)
	if fname == "" {
		return p.Email
	}

	return fname
}
389909
func (c *Cluster) SplitTable(mvccStore MVCCStore, tableID int64, count int) {
	tableStart := tablecodec.GenTableRecordPrefix(tableID)
	tableEnd := tableStart.PrefixNext()
	c.splitRange(mvccStore, NewMvccKey(tableStart), NewMvccKey(tableEnd), count)
}
1008939
func NormalizeNamesInTLF(g *libkb.GlobalContext, writerNames, readerNames []string,
	extensionSuffix string) (string, error) {
	sortedWriterNames := make([]string, len(writerNames))
	var err error
	for i, w := range writerNames {
		sortedWriterNames[i], err = NormalizeAssertionOrName(g, w)
		if err != nil {
			return "", err
		}
	}
	sort.Strings(sortedWriterNames)
	normalizedName := strings.Join(sortedWriterNames, ",")
	if len(readerNames) > 0 {
		sortedReaderNames := make([]string, len(readerNames))
		for i, r := range readerNames {
			sortedReaderNames[i], err = NormalizeAssertionOrName(g, r)
			if err != nil {
				return "", err
			}
		}
		sort.Strings(sortedReaderNames)
		normalizedName += ReaderSep + strings.Join(sortedReaderNames, ",")
	}
	if len(extensionSuffix) != 0 {
		// This *should* be normalized already but make sure.  I can see not
		// doing so might surprise a caller.
		normalizedName += TlfHandleExtensionSep + strings.ToLower(extensionSuffix)
	}

	return normalizedName, nil
}
1223710
func SplitMultiElement(r rune) ([]rune, bool) {
	r = CompatJamo(r)
	es, ok := multiElements[r]
	return es, ok
}
795078
func SplitLast(m Multiaddr) (Multiaddr, *Component) {
	// Shortcut if we already have a component
	if c, ok := m.(*Component); ok {
		return nil, c
	}

	b := m.Bytes()
	if len(b) == 0 {
		return nil, nil
	}

	var (
		c      Component
		err    error
		offset int
	)
	for {
		var n int
		n, c, err = readComponent(b[offset:])
		if err != nil {
			panic(err)
		}
		if len(b) == n+offset {
			// Reached end
			if offset == 0 {
				// Only one component
				return nil, &c
			}
			return &multiaddr{b[:offset]}, &c
		}
		offset += n
	}
}
1071526
func SplitHostname(named Named) (string, string) {
	name := named.Name()
	match := anchoredNameRegexp.FindStringSubmatch(name)
	if len(match) != 3 {
		return "", name
	}
	return match[1], match[2]
}
885263
func splitOption(prefix string, option string, islong bool) (string, string, *string) {
	if len(option) == 0 {
		return option, "", nil
	}

	// Windows typically uses a colon for the option name and argument
	// delimiter while POSIX typically uses an equals.  Support both styles,
	// but don't allow the two to be mixed.  That is to say /foo:bar and
	// --foo=bar are acceptable, but /foo=bar and --foo:bar are not.
	var pos int
	var sp string

	if prefix == "/" {
		sp = ":"
		pos = strings.Index(option, sp)
	} else if len(prefix) > 0 {
		sp = "="
		pos = strings.Index(option, sp)
	}

	if (islong && pos >= 0) || (!islong && pos == 1) {
		rest := option[pos+1:]
		return option[:pos], sp, &rest
	}

	return option, "", nil
}
767811
func ToFileName(name string) string {
	in := split(name)
	out := make([]string, 0, len(in))

	for _, w := range in {
		out = append(out, lower(w))
	}

	return strings.Join(out, "_")
}
216830
func split(str string) []string {
	// check if consecutive single char things make up an initialism
	once.Do(func() {
		splitRex1 = regexp.MustCompile(`(\p{Lu})`)
		splitRex2 = regexp.MustCompile(`(\pL|\pM|\pN|\p{Pc})+`)
		splitReplacer = strings.NewReplacer(
			"@", "At ",
			"&", "And ",
			"|", "Pipe ",
			"$", "Dollar ",
			"!", "Bang ",
			"-", " ",
			"_", " ",
		)
		ensureSorted()
	})

	str = trim(str)

	// Convert dash and underscore to spaces
	str = splitReplacer.Replace(str)

	// Split when uppercase is found (needed for Snake)
	str = splitRex1.ReplaceAllString(str, " $1")

	for _, k := range initialisms {
		str = strings.Replace(str, splitRex1.ReplaceAllString(k, " $1"), " "+k, -1)
	}
	// Get the final list of words
	//words = rex2.FindAllString(str, -1)
	return splitRex2.FindAllString(str, -1)
}
197400
func splitHostnamePartsFromHost(fullHost string, defaultPortNum string) (string, string) {

	h := strings.Split(fullHost, ":")

	if len(h) == 2 {
		return h[0], h[1]
	}

	return h[0], defaultPortNum
}
1136308
func SplitName(name string) (writerNames, readerNames []string,
	extensionSuffix string, err error) {
	assertions, extensionSuffix, err := SplitExtension(name)
	if err != nil {
		return nil, nil, "", err
	}

	splitNames := strings.SplitN(assertions, ReaderSep, 3)
	if len(splitNames) > 2 {
		return nil, nil, "", BadNameError{name}
	}
	writerNames = strings.Split(splitNames[0], ",")
	if len(splitNames) > 1 {
		readerNames = strings.Split(splitNames[1], ",")
	}

	return writerNames, readerNames, extensionSuffix, nil
}
231401
func SplitLDAPQuery(query string) (attributes, scope, filter, extensions string, err error) {
	parts := strings.Split(query, "?")
	switch len(parts) {
	case 4:
		extensions = parts[3]
		fallthrough
	case 3:
		if v, err := url.QueryUnescape(parts[2]); err != nil {
			return "", "", "", "", err
		} else {
			filter = v
		}
		fallthrough
	case 2:
		if v, err := url.QueryUnescape(parts[1]); err != nil {
			return "", "", "", "", err
		} else {
			scope = v
		}
		fallthrough
	case 1:
		if v, err := url.QueryUnescape(parts[0]); err != nil {
			return "", "", "", "", err
		} else {
			attributes = v
		}
		return attributes, scope, filter, extensions, nil
	case 0:
		return
	default:
		err = fmt.Errorf("too many query options %q", query)
		return "", "", "", "", err
	}
}