澳门威尼斯人注册网址【官网首页】
做最好的网站

SQL验证字符串是还是不是包涵有大小写字母,StringUtils学习笔记

来源:http://www.ogcoffee123.com 作者:威尼斯人官网 人气:140 发布时间:2019-11-30
摘要:  趁小编写例子那一点时间有四人应对了 呵呵 刚才试验过了 看下例子吗 JS 方法:复制代码 代码如下: 是或不是含有字符串示例代码 StringUtils.contains("abc", 'a') = trueStringUtils.contains("abc

 

趁小编写例子那一点时间有四人应对了 呵呵 刚才试验过了 看下例子吗 JS 方法: 复制代码 代码如下:

是或不是含有字符串示例代码

StringUtils.contains("abc", 'a') = trueStringUtils.contains("abc", 'z') = falseStringUtils.containsIgnoreCase("abc", "A") = trueStringUtils.containsIgnoreCase("abc", "Z") = falseStringUtils.containsWhitespace = falseStringUtils.containsWhitespace = trueStringUtils.containsAny("zzabyycdxx",['z','a']) = trueStringUtils.containsAny("zzabyycdxx",['b','y']) = trueStringUtils.containsAny("zzabyycdxx",['z','y']) = trueStringUtils.containsAny("aba", ['z']) = falseStringUtils.containsOnly("abab", 'abc') = trueStringUtils.containsOnly("ab1", 'abc') = falseStringUtils.containsOnly("abz", 'abc') = falseStringUtils.containsNone("abab", 'xyz') = trueStringUtils.containsNone("ab1", 'xyz') = trueStringUtils.containsNone("abz", 'xyz') = false
  • substring(final String str, int start):内定开端终结截取字符串;
  • substring(final String str, int start):钦点开端和得了截至截取字符串;
  • left(final String str, final int len):获得三个字符串最左边的len个字符;
  • right(final String str, final int len):获得一个字符串最侧边的len个字符;
  • mid(final String str, int pos, final int len):获得中间的内定区域的字符,是左包罗;
  • substringBefore(final String str, final String separator):获得三个字符串中率先个分割符此前的字符串;
  • substringAfter(final String str, final String separator):同理,获得五个字符串第叁个分割符之后的字符串;

Source Code

字符串字符串字符串字符串字符串字符串字符串字符串

截取字符串示例代码

StringUtils.substring = "c"StringUtils.substring = ""StringUtils.substring("abc", -2) = "bc"StringUtils.substring("abc", -4) = "abc"StringUtils.substring("abc", 2, 2) = ""StringUtils.substring("abc", -2, -1) = "b"StringUtils.substring("abc", -4, 2) = "ab"StringUtils.left = "ab"StringUtils.left = "abc"StringUtils.right = "bc"StringUtils.right = "abc"StringUtils.mid("abc", 2, 4) = "c"StringUtils.mid("abc", 4, 2) = ""StringUtils.mid("abc", -2, 2) = "ab"StringUtils.substringBefore("abcba", "b") = "a"StringUtils.substringBefore("abc", "c") = "ab"StringUtils.substringBefore("abc", "d") = "abc"StringUtils.substringAfter("abcba", "b") = "cba"StringUtils.substringAfter("abc", "c") = ""StringUtils.substringAfter("abc", "d") = ""
  • String[] split(final String str):依照空格分割字符串,再次来到数组;
  • String[] split(final String str, final char separatorChar):钦点分割符分割字符串;
  • String[] split(final String str, final String separatorChars, final int max):钦定分割符,钦赐最大分割的数组大小;
  • String[] splitByCharacterTypeCamelCase(final String str):根据字符串类型分割字符串;
DECLARE @s NVARCHAR(40) = N'SDFfgGRYJhhTYUJ'


IF LOWER(@s) COLLATE Latin1_General_CS_AS <> @s AND UPPER(@s) COLLATE Latin1_General_CS_AS <> @s
    PRINT 'T'
ELSE
    PRINT 'F'

字符串字符串字符串字符串字符串

剔除和替换字符串示例代码

StringUtils.removeStart("www.domain.com", "www.") = "domain.com"StringUtils.removeStart("domain.com", "www.") = "domain.com"StringUtils.removeStart("www.domain.com", "domain") = "www.domain.com"StringUtils.removeStart("abc", "") = "abc"StringUtils.deleteWhitespace = "abc"StringUtils.deleteWhitespace = "abc"StringUtils.removeEnd("www.domain.com", ".com.") = "www.domain.com"StringUtils.removeEnd("www.domain.com", ".com") = "www.domain"StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com"StringUtils.remove("queued", "ue") = "qd"StringUtils.remove("queued", "zz") = "queued"StringUtils.removeAll("any", ".*") = ""StringUtils.removeAll("any", ".+") = ""StringUtils.removeAll("abc", ".?") = ""StringUtils.removeAll("A&lt;__&gt;n&lt;__&gt;B", "&lt;.*&gt;") = "AnB"StringUtils.removeAll("A&lt;__&gt;n&lt;__&gt;B", "&lt;.*&gt;") = "AB"StringUtils.removeAll("ABCabc123abc", "[a-z]") = "ABC123"StringUtils.replaceOnce("aba", "a", null) = "aba"StringUtils.replaceOnce("aba", "a", "") = "ba"StringUtils.replaceOnce("aba", "a", "z") = "zba"StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "_") = "ABC_123"StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "") = "ABC123"StringUtils.replaceAll("abc", "", "ZZ") = "ZZaZZbZZcZZ"
  • repeat(final String str, final int repeat):生成钦命重复次数的双重字符串;

图片 1

字符串字符串字符串字符串字符串字符串字符串

字符串连接示例代码

StringUtils.join(["a", "b", "c"]) = "abc"StringUtils.join([null, "", "a"]) = "a"StringUtils.join(["a", "b", "c"], ';') = "a;b;c"StringUtils.join(["a", "b", "c"], null) = "abc"StringUtils.join([null, "", "a"], ';') = ";;a"
  • removeStart(final String str, final String remove):删除字符串中的钦赐的前缀字符串;
  • removeStartIgnoreCase(final String str, final String remove):同removeStart就好像,只是大体的高低写;
  • removeEnd(final String str, final String remove):同removeStart相反;
  • deleteWhitespace(final String str):删除字符串中的空格;
  • remove(final String str, final String remove):从字符串中移除钦点字符串;
  • removeAll(final String text, final String regex):移除符合正则表达式的具备字符串;
  • replaceOnce(final String text, final String searchString, final String replacement):将字符串中内定字符替换三个;
  • replaceAll(final String text, final String regex, final String replacement):将字符串中内定字符替换全部;

实时操作演示,空符串,全体大写,全体大写,大小混写等现象:
图片 2

字符串字符串字符串字符串字符串字符串字符串

字符串判空示例代码

StringUtils.isBlank; = trueStringUtils.isBlank; = trueStringUtils.isBlank; = trueStringUtils.isBlank; = falseStringUtils.isBlank; = falseStringUtils.isEmpty; = trueStringUtils.isEmpty; = trueStringUtils.isEmpty; = falseStringUtils.isEmpty; = falseStringUtils.isEmpty; = false

说明:isBlankisEmpty的区分在于在于空格字符串的判断差别;简言之,Empty认为空格字符不是空字符串

  • isAnyEmpty(final CharSequence... css):推断是不是存在空字符串;
  • isNoneEmpty(final CharSequence... css)认清任何都不是空字符串;
  • isAllEmpty(final CharSequence... css):决断整个为空字符串;
  • isAnyBlank(final CharSequence... css):推断是或不是留存空字符串;
  • isNoneBlank(final CharSequence... css)推断一切都不是空字符串;
  • isAllBlank(final CharSequence... css):判别任何为空字符串;

图片 3图片 4

请按F5刷新页面。。。。

字符串的退出示例代码

StringUtils.strip("abcde", "de"); = abcStringUtils.strip("abcde", "ed"); = abcStringUtils.stripStart("deabced", "ed"); = abcdStringUtils.stripStart("deabced", "de"); = abcdStringUtils.stripEnd(" abcyx", "xyz"); = " abc"StringUtils.stripEnd("120.00", ".0"); = "12"StringUtils.stripAll(["abc", " abc"]); = ["abc", "abc"]StringUtils.stripAll(["yabcz", null], "yz"); = ["abc", null]
  • equals(final CharSequence cs1, final CharSequence cs2):判定七个字符串是不是等于;
  • equalsIgnoreCase(final CharSequence str1, final CharSequence str2):剖断四个字符串在不经意大小写下是不是等于;
  • compare(final String str1, final String str2):相比较四个字符串长度的分寸;
  • compareIgnoreCase(final String str1, final String str2)忽略大小写下相比非常多少个字符串的轻重;
  • equalsAny(final CharSequence string, final CharSequence... searchStrings):比较多字符串中是还是不是存在相通的字符串;
  • equalsAnyIgnoreCase(final CharSequence string, final CharSequence...searchStrings):忽视大小写是不是留存相通字符

今早有贯彻二个小效用,就是在MS SQL Server中,检查字符串是或不是含有有大大小小写字母。常常接纳在字符串的复杂度。

字符串字符串字符串字符串字符串字符串字符串字符串字符串

字符串的检索示例代码

StringUtils.indexOf("aabaabaa", 'b') = 2StringUtils.indexOf("aabaabaa", "") = 0StringUtils.indexOf("aabaabaa", "b", 3) = 5StringUtils.ordinalIndexOf("abababab", "abab", 3) = 4StringUtils.lastIndexOf("aabaabaa", 'b') = 5StringUtils.lastIndexOf("aabaabaa", 'a', 0) = 0
  • contains(final CharSequence seq, final int searchChar:是不是带有钦命字符串;
  • containsIgnoreCase(final CharSequence str, final CharSequence searchStr:忽视大小写下检查是还是不是带有钦点字符串
  • containsWhitespace(final CharSequence seq):是或不是包括空白字符串;
  • containsAny(final CharSequence cs, final char... searchChars):剖断字符窜是或不是含有后边六个中的大肆一个;
  • containsOnly(final CharSequence cs, final char... valid):决断前方的字符是或不是全是后边的字符中的;
  • containsNone(final CharSequence cs, final char... searchChars):判定前方字符是不是不含其后字符的任意一个字符

字符串的可比代码示例

StringUtils.equals("abc", null) = falseStringUtils.equals("abc", "abc") = trueStringUtils.equals("abc", "ABC") = falsetringUtils.equalsIgnoreCase("abc", "ABC") = trueStringUtils.compare("abc", "abc") = 0StringUtils.compare > 0StringUtils.compare < 0StringUtils.compare < 0StringUtils.compare("ab", "abc") < 0StringUtils.compareIgnoreCase < 0StringUtils.compareIgnoreCase < 0StringUtils.compareIgnoreCase("ab", "ABC") < 0StringUtils.equalsAny("abc", "abc", "def") = trueStringUtils.equalsAny("abc", "ABC", "DEF") = falseStringUtils.equalsAnyIgnoreCase("abc", "abc", "def") = trueStringUtils.equalsAnyIgnoreCase("abc", "ABC", "DEF") = true
  • indexOf(final CharSequence seq, final int searchChar):查找钦定字符在字符串中首次出现的岗位的索引值;
  • indexOf(final CharSequence seq, final int searchChar, final int startPos):从内定地点final int startPos起先查找;
  • indexOfIgnoreCase(final CharSequence str, final CharSequence searchStr):忽视大小写的寻觅字符串第贰次出现岗位
  • indexOfIgnoreCase(final CharSequence str, final CharSequence searchStr, int startPos):同``indexOf`类似;
  • lastIndexOf(final CharSequence seq, final int searchChar):从尾巴部分起头查找;
  • lastIndexOf(final CharSequence seq, final int searchChar, final int startPos):同理从尾部领头查找钦赐地方前的字符

删除字符串前后空格示例代码

StringUtils.trim = nullStringUtils.trim = ""StringUtils.trimToNull = nullStringUtils.trimToNull = nullStringUtils.trimToEmpty = ""StringUtils.trimToEmpty = ""
  • truncate(final String str, final int maxWidth):截取字符串的前maxWidth个字符;
    • 如果str的长短小于maxWidth就径直回到str
    • 如果maxWidth小于0则抛出IllegalArgumentException异常;
  • truncate(final String str, final int offset, final int maxWidth):截取钦赐区域的字符串;

字符串分割示例代码

StringUtils.split("abc def") = ["abc", "def"]StringUtils.split = ["abc"]StringUtils.split("a..b.c", '.') = ["a", "b", "c"]StringUtils.split("a:b:c", '.') = ["a:b:c"]StringUtils.split("a b c", ' ') = ["a", "b", "c"]StringUtils.split("ab:cd:ef", ":", 3); = [ab, cd, ef]StringUtils.split("ab:cd:ef", ":", 2); = [ab:cd:ef]StringUtils.split("ab:cd:ef", ":", 1); = [ab, cd:ef]StringUtils.splitByCharacterTypeCamelCase("number5") = ["number", "5"]StringUtils.splitByCharacterTypeCamelCase = ["foo", "Bar"]StringUtils.splitByCharacterTypeCamelCase("foo200Bar") = ["foo", "200", "Bar"]StringUtils.splitByCharacterTypeCamelCase("ASFRules") = ["ASF", "Rules"]
  • join(final T... elements);普通的连年字符串
  • join(final Object[] array, final char separator):钦赐连接符,连接字符串;

看清是还是不是留存空字符串示例代码

StringUtils.isAnyBlank = trueStringUtils.isAnyBlank(null, "foo") = trueStringUtils.isAnyBlank(null, null) = trueStringUtils.isAnyBlank("", "bar") = trueStringUtils.isAnyBlank("bob", "") = trueStringUtils.isAnyBlank(" bob ", null) = trueStringUtils.isAnyBlank(" ", "bar") = trueStringUtils.isAnyBlank(new String[] {}) = falseStringUtils.isAnyBlank(new String[]{""}) = trueStringUtils.isAnyBlank("foo", "bar") = false

说明:同理,这里的分别也是在于空格字符串的差异对待;

  • trim(final String str):去除字符串前后空格,同不常间不转移原字符串;
  • trimToNull(final String str):去除字符串前后空格,假如剔除后是空字符串就转为null;
  • trimToEmpty(final String str):去除字符串前后空格,即便去除后是空字符串就转为空字符串(null转为"");
  • strip(final String str):这一个也得以去除字符串的前后空格,不改造原字符串;
  • stripToNull(String str):同trimToNull(final String str)类似;
  • stripToEmpty(final String str):同trimToEmpty(final String str)类似;

再度字符串生成示例代码

StringUtils.repeat = "aaa"StringUtils.repeat = "abab"StringUtils.repeat = ""
  • countMatches(final CharSequence str, final CharSequence sub):获取钦定字符串在原字符串中现身的次数;

字符串截取示例代码

StringUtils.truncate = nullStringUtils.truncate = nullStringUtils.truncate = ""StringUtils.truncate("abcdefg", 4) = "abcd"StringUtils.truncate(null, 0, 0) = nullStringUtils.truncate(null, 2, 4) = nullStringUtils.truncate("", 0, 10) = ""StringUtils.truncate("", 2, 10) = ""StringUtils.truncate("abcdefghij", 0, 3) = "abc"StringUtils.truncate("abcdefghij", 5, 6) = "fghij"StringUtils.truncate("abcdefghijklmno", -1, 10) = throws an IllegalArgumentExceptionStringUtils.truncate("abcdefghijklmno", Integer.MIN_VALUE, 10) = "abcdefghij"StringUtils.truncate("abcdefghijklmno", 0, Integer.MAX_VALUE) = "abcdefghijklmno"

表明:更加多的演示代码能够参见StringUtils源码;

  • strip(String str, final String stripChars):从str的上下分离stripChars字符串;
  • stripStart(final String str, final String stripChars):从上马的地点剥离内定字符串;
  • stripEnd(final String str, final String stripChars):从截止的地点分离字符串;
  • String[] stripAll(final String... strs):对数组中的全部字符串举行去除空格;
  • String[] stripAll(final String[] strs, final String stripChars):对数组中的每一个字符串举行字符串抽离;
  • isBlank(final CharSequence cs):判定是空字符串;
  • isNotBlank(final CharSequence cs):决断不是空字符串;
  • isEmpty(final CharSequence cs):判别是空字符串;
  • isNotEmpty(final CharSequence cs):决断不是空字符串;

字符串现身次数示例代码

StringUtils.countMatches("abba", "a") = 2StringUtils.countMatches("abba", "ab") = 1
  • isNumericSpace(final CharSequence cs)
StringUtils.isNumericSpace = trueStringUtils.isNumericSpace = false
  • isWhitespace(final CharSequence cs)
StringUtils.isWhitespace = trueStringUtils.isWhitespace = trueStringUtils.isWhitespace = false
  • isAllLowerCase(final CharSequence cs)
StringUtils.isAllLowerCase = trueStringUtils.isAllLowerCase = false
  • isAllUpperCase(final CharSequence cs)
StringUtils.isAllUpperCase = trueStringUtils.isAllUpperCase = false
  • reverse(final String str)
StringUtils.reverse = "tab"
  • abbreviate(final String str, final int maxWidth)
StringUtils.abbreviate("abcdefg", 6) = "abc..."StringUtils.abbreviate("abcdefg", 7) = "abcdefg"StringUtils.abbreviate("abcdefg", 8) = "abcdefg"StringUtils.abbreviate("abcdefg", 4) = "a..."
  • startsWith(final CharSequence str, final CharSequence prefix)
StringUtils.startsWith("abcdef", null) = falseStringUtils.startsWith("abcdef", "abc") = trueStringUtils.startsWith("ABCDEF", "abc") = false
  • endsWith(final CharSequence str, final CharSequence suffix)
StringUtils.endsWith("ABCDEF", "def") = falseStringUtils.endsWith("ABCDEF", "cde") = falseStringUtils.endsWith("ABCDEF", "") = true

本文由澳门威尼斯人注册网址发布于威尼斯人官网,转载请注明出处:SQL验证字符串是还是不是包涵有大小写字母,StringUtils学习笔记

关键词:

最火资讯