v1.16.9
ADDED: * netx.IsPub * encodingx/hexx Rest are mostly small corrections and docs
This commit is contained in:
@@ -10,6 +10,53 @@ import (
|
||||
`unicode`
|
||||
)
|
||||
|
||||
/*
|
||||
HasBookend returns true if string s both begins AND ends with sym.
|
||||
|
||||
It is more strict than [HasBoundary] (which only requires
|
||||
that s has sym at the beginning OR the end.)
|
||||
|
||||
Examples:
|
||||
HasBookend("|foo|", "|") → true
|
||||
HasBookend("|foo", "|") → false
|
||||
HasBookend("foo|", "|") → false
|
||||
HasBookend("fo|o", "|") → false
|
||||
HasBookend("|foo| ", "|") → false // Whitespace prevents match
|
||||
HasBookend(" |foo| ", "|") → false
|
||||
|
||||
sym may be a multi-rune string.
|
||||
If sym is empty, HasBookend will *always* return true.
|
||||
*/
|
||||
func HasBookend(s, sym string) (bounded bool) {
|
||||
|
||||
bounded = strings.HasPrefix(s, sym) && strings.HasSuffix(s, sym)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
HasBoundary returns true if string s starts OR ends with symbol sym.
|
||||
|
||||
Examples:
|
||||
HasBoundary("|foo|", "|") → true
|
||||
HasBoundary("|foo", "|") → true
|
||||
HasBoundary("foo|", "|") → true
|
||||
HasBoundary("fo|o", "|") → false
|
||||
HasBoundary("|foo| ", "|") → true
|
||||
HasBoundary(" |foo| ", "|") → false // Whitespace prevents match
|
||||
|
||||
sym may be a multi-rune string.
|
||||
If sym is empty, HasBoundary will *always* return true.
|
||||
|
||||
If you instead require string s to be *enclosed* by sym, see [HasBookend].
|
||||
*/
|
||||
func HasBoundary(s, sym string) (bounded bool) {
|
||||
|
||||
bounded = strings.HasPrefix(s, sym) || strings.HasSuffix(s, sym)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
IsAscii returns true if all characters in string s are ASCII.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user