This is what I am trying but it seems not to work:
(myStringHere.split(".")[(myStringHere.split(".").length)-1]).concat(text[myStringHere])
The string I have will be something like this:
com.foo.bar.zar.gar.ThePartIWant
ThePartIWant is what I want to show in the page only.
I am using Expression Language 2.2
If you are doing it in JSP then try with JSP JSTL function tag library that provide lost of methods as defined here in JavaDoc
Read more here on Oacle The Java EE 5 Tutorial - JSTL Functions
Here is the code to get the last value based on split on dot.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
...
<c:set var="string1" value="This.is.first.String." />
<c:set var="string2" value="${fn:split(string1, '.')}" />
<c:set var="lastString" value="${string2[fn:length(string2)-1]}" />
<c:out value="${lastString }"></c:out>
output:
String
Here is one more example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With