Module: stdgo.strings
Overview
Index
-
function cut(_s:String, _sep:String):stdgo.Tuple3<String, String, Bool>
-
function cutPrefix(_s:String, _prefix:String):stdgo.Tuple<String, Bool>
-
function cutSuffix(_s:String, _suffix:String):stdgo.Tuple<String, Bool>
-
function dumpTables(_pattern:String):stdgo.Tuple<Array<Int>, Array<Int>>
-
function newReplacer(_oldnew:haxe.Rest<String>):stdgo.strings.Replacer
-
function replace(_s:String, _old:String, _new:String, _n:Int):String
-
function replaceAll(_s:String, _old:String, _new:String):String
-
function splitAfterN(_s:String, _sep:String, _n:Int):Array<String>
-
function splitN(_s:String, _sep:String, _n:Int):Array<String>
-
function toLowerSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:String):String
-
function toTitleSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:String):String
-
function toUpperSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:String):String
Classes
import
class Strings
{
i_3210759 = 0
_ = 0
gotoNext = 3210767
_ = gotoNext == 3210767
if i_3210759 < len(s) && i_3210759 < len(t) {
gotoNext = 3210803
_ = gotoNext == 3210803
sr_3210807 = s[i_3210759]
tr_3210820 = t[i_3210759]
if sr_3210807|tr_3210820 >= 128 {
gotoNext = 3210859
_ = gotoNext == 3210859
gotoNext = 3211217
gotoNext = 3210903
} else {
gotoNext = 3210903
}
_ = gotoNext == 3210903
if tr_3210820 == sr_3210807 {
gotoNext = 3210915
_ = gotoNext == 3210915
i_3210759++
gotoNext = 3210767
gotoNext = 3210980
} else {
gotoNext = 3210980
}
_ = gotoNext == 3210980
if tr_3210820 < sr_3210807 {
gotoNext = 3210991
_ = gotoNext == 3210991
tr_3210820, sr_3210807 = sr_3210807, tr_3210820
gotoNext = 3211066
} else {
gotoNext = 3211066
}
_ = gotoNext == 3211066
if 65 <= sr_3210807 && sr_3210807 <= 90 && tr_3210820 == sr_3210807+97-65 {
gotoNext = 3211112
_ = gotoNext == 3211112
i_3210759++
gotoNext = 3210767
gotoNext = 3211132
} else {
gotoNext = 3211132
}
_ = gotoNext == 3211132
return false
i_3210759++
gotoNext = 3210767
} else {
gotoNext = 3211192
}
_ = gotoNext == 3211192
return len(s) == len(t)
gotoNext = 3211217
_ = gotoNext == 3211217
s = s[i_3210759:]
t = t[i_3210759:]
keys_3211252 = []int{}
values_3211252 = []rune{}
for key, value := range s {
keys_3211252 = append(keys_3211252, key)
values_3211252 = append(values_3211252, value)
}
if 0 < len(keys_3211252) {
gotoNext = 3212183
_ = gotoNext == 3212183
i_3211265 = 0
gotoNext = 3212184
_ = gotoNext == 3212184
if i_3211265 < len(keys_3211252) {
gotoNext = 3211273
_ = gotoNext == 3211273
sr_3211259 = values_3211252[i_3211265]
_ = keys_3211252[i_3211265]
if len(t) == 0 {
gotoNext = 3211342
_ = gotoNext == 3211342
return false
gotoNext = 3211411
} else {
gotoNext = 3211411
}
_ = gotoNext == 3211411
if t[0] < 128 {
gotoNext = 3211449
_ = gotoNext == 3211449
tr_3211415, t = rune(t[0]), t[1:]
gotoNext = 3211633
} else {
gotoNext = 3211489
_ = gotoNext == 3211489
r_3211494, size_3211497 = utf8.DecodeRuneInString(t)
tr_3211415, t = r_3211494, t[size_3211497:]
gotoNext = 3211633
}
_ = gotoNext == 3211633
if tr_3211415 == sr_3211259 {
gotoNext = 3211645
_ = gotoNext == 3211645
i_3211265++
gotoNext = 3212184
gotoNext = 3211710
} else {
gotoNext = 3211710
}
_ = gotoNext == 3211710
if tr_3211415 < sr_3211259 {
gotoNext = 3211721
_ = gotoNext == 3211721
tr_3211415, sr_3211259 = sr_3211259, tr_3211415
gotoNext = 3211775
} else {
gotoNext = 3211775
}
_ = gotoNext == 3211775
if tr_3211415 < 128 {
gotoNext = 3211797
_ = gotoNext == 3211797
if 65 <= sr_3211259 && sr_3211259 <= 90 && tr_3211415 == sr_3211259+97-65 {
gotoNext = 3211897
_ = gotoNext == 3211897
i_3211265++
gotoNext = 3212184
gotoNext = 3211920
} else {
gotoNext = 3211920
}
_ = gotoNext == 3211920
return false
gotoNext = 3212050
} else {
gotoNext = 3212050
}
_ = gotoNext == 3212050
r_3212050 = unicode.SimpleFold(sr_3211259)
_ = 0
gotoNext = 3212080
_ = gotoNext == 3212080
if r_3212050 != sr_3211259 && r_3212050 < tr_3211415 {
gotoNext = 3212102
_ = gotoNext == 3212102
r_3212050 = unicode.SimpleFold(r_3212050)
gotoNext = 3212080
} else {
gotoNext = 3212139
}
_ = gotoNext == 3212139
if r_3212050 == tr_3211415 {
gotoNext = 3212150
_ = gotoNext == 3212150
i_3211265++
gotoNext = 3212184
gotoNext = 3212170
} else {
gotoNext = 3212170
}
_ = gotoNext == 3212170
return false
i_3211265++
gotoNext = 3212184
} else {
gotoNext = 3212257
}
gotoNext = 3212257
} else {
gotoNext = 3212257
}
_ = gotoNext == 3212257
return len(t) == 0
gotoNext = -1
}
Strings function clone
function clone(_s:String):String
Clone returns a fresh copy of s.
It guarantees to make a copy of s into a new allocation,
which can be important when retaining only a small substring
of a much larger string. Using Clone can help such programs
use less memory. Of course, since using Clone makes a copy,
overuse of Clone can make programs use more memory.
Clone should typically be used only rarely, and only when
profiling indicates that it is needed.
For strings of length zero the string "" will be returned
and no allocation is made.
Strings function compare
function compare(_a:String, _b:String):Int
Compare returns an integer comparing two strings lexicographically.
The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
Compare is included only for symmetry with package bytes. It is usually clearer and always faster to use the built-in string comparison operators ==, \<, \>, and so on.
Strings function contains
function contains(_s:String, _substr:String):Bool
Contains reports whether substr is within s.
Strings function containsAny
function containsAny(_s:String, _chars:String):Bool
ContainsAny reports whether any Unicode code points in chars are within s.
Strings function containsFunc
function containsFunc(_s:String, _f:()):Bool
ContainsFunc reports whether any Unicode code points r within s satisfy f(r).
Strings function containsRune
function containsRune(_s:String, _r:Int):Bool
ContainsRune reports whether the Unicode code point r is within s.
Strings function count
function count(_s:String, _substr:String):Int
Count counts the number of non-overlapping instances of substr in s.
If substr is an empty string, Count returns 1 + the number of Unicode code points in s.
Strings function cut
function cut(_s:String, _sep:String):stdgo.Tuple3<String, String, Bool>
Cut slices s around the first instance of sep,
returning the text before and after sep.
The found result reports whether sep appears in s.
If sep does not appear in s, cut returns s, "", false.
Strings function cutPrefix
function cutPrefix(_s:String, _prefix:String):stdgo.Tuple<String, Bool>
CutPrefix returns s without the provided leading prefix string
and reports whether it found the prefix.
If s doesn't start with prefix, CutPrefix returns s, false.
If prefix is the empty string, CutPrefix returns s, true.
Strings function cutSuffix
function cutSuffix(_s:String, _suffix:String):stdgo.Tuple<String, Bool>
CutSuffix returns s without the provided ending suffix string
and reports whether it found the suffix.
If s doesn't end with suffix, CutSuffix returns s, false.
If suffix is the empty string, CutSuffix returns s, true.
Strings function dumpTables
function dumpTables(_pattern:String):stdgo.Tuple<Array<Int>, Array<Int>>
Strings function equalFold
function equalFold(_s:String, _t:String):Bool
EqualFold reports whether s and t, interpreted as UTF-8 strings,
are equal under simple Unicode case-folding, which is a more general
form of case-insensitivity.
Strings function fields
function fields(_s:String):Array<String>
Fields splits the string s around each instance of one or more consecutive white space
characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an
empty slice if s contains only white space.
Strings function fieldsFunc
function fieldsFunc(_s:String, _f:()):Array<String>
FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c)
and returns an array of slices of s. If all code points in s satisfy f(c) or the
string is empty, an empty slice is returned.
FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.
Strings function hasPrefix
function hasPrefix(_s:String, _prefix:String):Bool
HasPrefix tests whether the string s begins with prefix.
Strings function hasSuffix
function hasSuffix(_s:String, _suffix:String):Bool
HasSuffix tests whether the string s ends with suffix.
Strings function index
function index(_s:String, _substr:String):Int
Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
Strings function indexAny
function indexAny(_s:String, _chars:String):Int
IndexAny returns the index of the first instance of any Unicode code point
from chars in s, or -1 if no Unicode code point from chars is present in s.
Strings function indexByte
function indexByte(_s:String, _c:UInt):Int
IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
Strings function indexFunc
function indexFunc(_s:String, _f:()):Int
IndexFunc returns the index into s of the first Unicode
code point satisfying f(c), or -1 if none do.
Strings function indexRune
function indexRune(_s:String, _r:Int):Int
IndexRune returns the index of the first instance of the Unicode code point
r, or -1 if rune is not present in s.
If r is utf8.RuneError, it returns the first instance of any
invalid UTF-8 byte sequence.
Strings function join
function join(_elems:Array<String>, _sep:String):String
Join concatenates the elements of its first argument to create a single string. The separator
string sep is placed between elements in the resulting string.
Strings function lastIndex
function lastIndex(_s:String, _substr:String):Int
LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
Strings function lastIndexAny
function lastIndexAny(_s:String, _chars:String):Int
LastIndexAny returns the index of the last instance of any Unicode code
point from chars in s, or -1 if no Unicode code point from chars is
present in s.
Strings function lastIndexByte
function lastIndexByte(_s:String, _c:UInt):Int
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
Strings function lastIndexFunc
function lastIndexFunc(_s:String, _f:()):Int
LastIndexFunc returns the index into s of the last
Unicode code point satisfying f(c), or -1 if none do.
Strings function map_
function map_(_mapping:(), _s:String):String
Map returns a copy of the string s with all its characters modified
according to the mapping function. If mapping returns a negative value, the character is
dropped from the string with no replacement.
Strings function newReader
function newReader(_s:String):stdgo.strings.Reader
NewReader returns a new Reader reading from s.
It is similar to bytes.NewBufferString but more efficient and non-writable.
Strings function newReplacer
function newReplacer(_oldnew:haxe.Rest<String>):stdgo.strings.Replacer
NewReplacer returns a new Replacer from a list of old, new string
pairs. Replacements are performed in the order they appear in the
target string, without overlapping matches. The old string
comparisons are done in argument order.
NewReplacer panics if given an odd number of arguments.
Strings function repeat
function repeat(_s:String, _count:Int):String
Repeat returns a new string consisting of count copies of the string s.
It panics if count is negative or if the result of (len(s) * count) overflows.
Strings function replace
function replace(_s:String, _old:String, _new:String, _n:Int):String
Replace returns a copy of the string s with the first n
non-overlapping instances of old replaced by new.
If old is empty, it matches at the beginning of the string
and after each UTF-8 sequence, yielding up to k+1 replacements
for a k-rune string.
If n < 0, there is no limit on the number of replacements.
Strings function replaceAll
function replaceAll(_s:String, _old:String, _new:String):String
ReplaceAll returns a copy of the string s with all
non-overlapping instances of old replaced by new.
If old is empty, it matches at the beginning of the string
and after each UTF-8 sequence, yielding up to k+1 replacements
for a k-rune string.
Strings function split
function split(_s:String, _sep:String):Array<String>
Split slices s into all substrings separated by sep and returns a slice of
the substrings between those separators.
If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.
It is equivalent to SplitN with a count of -1.
To split around the first instance of a separator, see Cut.
Strings function splitAfter
function splitAfter(_s:String, _sep:String):Array<String>
SplitAfter slices s into all substrings after each instance of sep and
returns a slice of those substrings.
If s does not contain sep and sep is not empty, SplitAfter returns a slice of length 1 whose only element is s.
If sep is empty, SplitAfter splits after each UTF-8 sequence. If both s and sep are empty, SplitAfter returns an empty slice.
It is equivalent to SplitAfterN with a count of -1.
Strings function splitAfterN
function splitAfterN(_s:String, _sep:String, _n:Int):Array<String>
SplitAfterN slices s into substrings after each instance of sep and
returns a slice of those substrings.
The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder.
n == 0: the result is nil (zero substrings)
n < 0: all substrings
Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for SplitAfter.
Strings function splitN
function splitN(_s:String, _sep:String, _n:Int):Array<String>
SplitN slices s into substrings separated by sep and returns a slice of
the substrings between those separators.
The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder.
n == 0: the result is nil (zero substrings)
n < 0: all substrings
Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.
To split around the first instance of a separator, see Cut.
Strings function stringFind
function stringFind(_pattern:String, _text:String):Int
Strings function title
function title(_s:String):String
Title returns a copy of the string s with all Unicode letters that begin words
mapped to their Unicode title case.
Deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
Strings function toLower
function toLower(_s:String):String
ToLower returns s with all Unicode letters mapped to their lower case.
Strings function toLowerSpecial
function toLowerSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:String):String
ToLowerSpecial returns a copy of the string s with all Unicode letters mapped to their
lower case using the case mapping specified by c.
Strings function toTitle
function toTitle(_s:String):String
ToTitle returns a copy of the string s with all Unicode letters mapped to
their Unicode title case.
Strings function toTitleSpecial
function toTitleSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:String):String
ToTitleSpecial returns a copy of the string s with all Unicode letters mapped to their
Unicode title case, giving priority to the special casing rules.
Strings function toUpper
function toUpper(_s:String):String
ToUpper returns s with all Unicode letters mapped to their upper case.
Strings function toUpperSpecial
function toUpperSpecial(_c:stdgo._internal.unicode.SpecialCase, _s:String):String
ToUpperSpecial returns a copy of the string s with all Unicode letters mapped to their
upper case using the case mapping specified by c.
Strings function toValidUTF8
function toValidUTF8(_s:String, _replacement:String):String
ToValidUTF8 returns a copy of the string s with each run of invalid UTF-8 byte sequences
replaced by the replacement string, which may be empty.
Strings function trim
function trim(_s:String, _cutset:String):String
Trim returns a slice of the string s with all leading and
trailing Unicode code points contained in cutset removed.
Strings function trimFunc
function trimFunc(_s:String, _f:()):String
TrimFunc returns a slice of the string s with all leading
and trailing Unicode code points c satisfying f(c) removed.
Strings function trimLeft
function trimLeft(_s:String, _cutset:String):String
TrimLeft returns a slice of the string s with all leading
Unicode code points contained in cutset removed.
To remove a prefix, use TrimPrefix instead.
Strings function trimLeftFunc
function trimLeftFunc(_s:String, _f:()):String
TrimLeftFunc returns a slice of the string s with all leading
Unicode code points c satisfying f(c) removed.
Strings function trimPrefix
function trimPrefix(_s:String, _prefix:String):String
TrimPrefix returns s without the provided leading prefix string.
If s doesn't start with prefix, s is returned unchanged.
Strings function trimRight
function trimRight(_s:String, _cutset:String):String
TrimRight returns a slice of the string s, with all trailing
Unicode code points contained in cutset removed.
To remove a suffix, use TrimSuffix instead.
Strings function trimRightFunc
function trimRightFunc(_s:String, _f:()):String
TrimRightFunc returns a slice of the string s with all trailing
Unicode code points c satisfying f(c) removed.
Strings function trimSpace
function trimSpace(_s:String):String
TrimSpace returns a slice of the string s, with all leading
and trailing white space removed, as defined by Unicode.
Strings function trimSuffix
function trimSuffix(_s:String, _suffix:String):String
TrimSuffix returns s without the provided trailing suffix string.
If s doesn't end with suffix, s is returned unchanged.
Typedefs
import
typedef T_appendSliceWriter
typedef T_appendSliceWriter = stdgo._internal.strings.T_appendSliceWriter;
typedef T_asciiSet
typedef T_asciiSet = stdgo._internal.strings.T_asciiSet;
typedef T_byteReplacer
typedef T_byteReplacer = stdgo._internal.strings.T_byteReplacer;
typedef T_replacer
typedef T_replacer = stdgo._internal.strings.T_replacer;