<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> JSTL Functions • Substring Contained in String

Substring Contained in String

fn:contains

Input String Substring Result
${s1} castle ${fn:contains(s1, "castle")}
${s1} CASTLE ${fn:contains(s1, "CASTLE")}
${s1} null ${fn:contains(s1, undefined)}
${s1} empty string ${fn:contains(s1, "")}
null castle ${fn:contains(undefined, "castle")}
null empty string ${fn:contains(undefined, "")}

fn:containsIgnoreCase

Input String Substring Result
${s1} castle ${fn:containsIgnoreCase(s1, "castle")}
${s1} CASTLE ${fn:containsIgnoreCase(s1, "CASTLE")}
${s1} CaStLe ${fn:containsIgnoreCase(s1, "CaStLe")}
${s1} null ${fn:containsIgnoreCase(s1, undefined)}
${s1} empty string ${fn:containsIgnoreCase(s1, "")}
null castle ${fn:containsIgnoreCase(undefined, "castle")}
null empty string ${fn:containsIgnoreCase(undefined, "")}

fn:startsWith

Input String Substring Result
${s1} castle ${fn:startsWith(s1, "castle")}
${s1} There is ${fn:startsWith(s1, "There is")}
${s1} null ${fn:startsWith(s1, undefined)}
${s1} empty string ${fn:startsWith(s1, "")}
null castle ${fn:startsWith(undefined, "castle")}
null empty string ${fn:startsWith(undefined, "")}

fn:endsWith

Input String Substring Result
${s1} castle ${fn:endsWith(s1, "castle")}
${s1} cloud ${fn:endsWith(s1, "cloud")}
${s1} null ${fn:endsWith(s1, undefined)}
${s1} empty string ${fn:endsWith(s1, "")}
null castle ${fn:endsWith(undefined, "castle")}
null empty string ${fn:endsWith(undefined, "")}

fn:indexOf

Input String Substring Result
${s1} castle ${fn:indexOf(s1, "castle")}
${s1} cloud ${fn:indexOf(s1, "cloud")}
${s1} null ${fn:indexOf(s1, undefined)}
${s1} empty string ${fn:indexOf(s1, "")}
null castle ${fn:indexOf(undefined, "castle")}
null empty string ${fn:indexOf(undefined, "")}
Display text in between brackets
${text} '(' and ')' ${fn:substring(text, fn:indexOf(text, '(')+1, fn:indexOf(text, ')'))}