Ai
1 Star 11 Fork 3

ZX/php-code-generator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
utils_str.go 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
ZX 提交于 2023-09-16 14:26 +08:00 . 增加goravel工具库
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gconv
import "strings"
// IsLetterUpper tests whether the given byte b is in upper case.
func IsLetterUpper(b byte) bool {
if b >= byte('A') && b <= byte('Z') {
return true
}
return false
}
// IsLetterLower tests whether the given byte b is in lower case.
func IsLetterLower(b byte) bool {
if b >= byte('a') && b <= byte('z') {
return true
}
return false
}
// IsNumeric tests whether the given string s is numeric.
// Note that float string like "123.456" is also numeric.
func IsNumeric(s string) bool {
length := len(s)
if length == 0 {
return false
}
for i := 0; i < len(s); i++ {
if s[i] == '-' && i == 0 {
continue
}
if s[i] == '.' {
if i > 0 && i < len(s)-1 {
continue
} else {
return false
}
}
if s[i] < '0' || s[i] > '9' {
return false
}
}
return true
}
// UcFirst returns a copy of the string s with the first letter mapped to its upper case.
func UcFirst(s string) string {
if len(s) == 0 {
return s
}
if IsLetterLower(s[0]) {
return string(s[0]-32) + s[1:]
}
return s
}
// ReplaceByMap returns a copy of <origin>,
// which is replaced by a map in unordered way, case-sensitively.
func ReplaceByMap(origin string, replaces map[string]string) string {
for k, v := range replaces {
origin = strings.Replace(origin, k, v, -1)
}
return origin
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/open-php/php-code-generator.git
git@gitee.com:open-php/php-code-generator.git
open-php
php-code-generator
php-code-generator
v0.1.0

搜索帮助