fn:containsIgnoreCase 函数用于判断在源字符串中是否包含目标字符串,并且在判断时忽略大小写,其语法为:
fn: containsIgnoreCase (String source,String target) -------boolean;
以上 source 参数指定源字符串, target 参数指定目标字符串,返回类型为 boolean 。
例如对于以下 EL 表达式:
${fn: containsIgnoreCase (“Tomcat”,”CAT”)}
${fn: containsIgnoreCase (“Tomcat”,”Mike”)}
第一个 EL 表达式的值为 true ,第二个 EL 表达式的值为 false 。
18.3 fn:startsWith 函数
fn:startsWith 函数用于判断源字符串是否以指定的目标字符串开头,其语法为:
fn:startsWith(String source,String target) ----boolean
以上 source 参数指定源字符串, target 参数指定目标字符串,返回类型为 boolean 。
例如对于以下 EL 表达式:
${fn: startsWith (“Tomcat”,”Tom”)}
${fn: startsWith (“Tomcat”,”cat”)}
第一个 EL 表达式的值为 true ,第二个 EL 表达式的值为 false 。
18.4 fn:endsWith 函数
fn: endsWith 函数用于判断源字符串是否以指定的目标字符串结尾,其语法为:
fn: endsWith (String source,String target) ----boolean
以上 source 参数指定源字符串, target 参数指定目标字符串,返回类型为 boolean 。
例如对于以下 EL 表达式:
${fn: endsWith (“Tomcat”,”cat”)}
${fn: endsWith (“Tomcat”,”Tom”)}
第一个 EL 表达式的值为 true ,第二个 EL 表达式的值为 false 。
18.5 fn:indexOf 函数
fn:indexOf 函数用于在源字符串中查找目标字符串,并返回源字符串中最先与目标字符串匹配的第一个字符的索引,如果在源字符串中不包含目标字符串,就返回 -1 ,源字符串中的第一个字符的索引为 0 。 fn:indexOf 函数的语法为:
fn: indexOf (String source,String target) ----int
以上 source 参数指定源字符串, target 参数指定目标字符串,返回类型为 int 。
例如对于以下 EL 表达式:
1 ${fn: indexOf (“Tomcat”,”cat”)}<br/>
2 ${fn: indexOf (“2211221”,”21”)} <br/>
3 ${fn: indexOf (“Tomcat”,”Mike”)} <br/>
其输出结果为:
1 3
2 1
3 -1
18.6 fn:replace 函数
fn:replace 函数用于把源字符串中的一部分替换为另外的字符串,并返回替换后的字符串。 fn:replace 函数的语法为:
fn: replace (String source,String before,String after) ----String
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-32905-17.html
该吃吃