Question

I have this value

<c:set var="string1" value="SS4444"/>

What I am try to achieve is to get the numbers only (4444) from the above variable. I can use substring, but the index value might change, ie it can be 'SS4444', 'S4444', 'SSS444', so cant rely on static index.

Thanks in advance

Was it helpful?

Solution

Split it with regex.. (substringAfter is not proper for this..):

<c:forEach var="string1" items="${fn:split(yourstring, '^\w*')}">
                    <c:set var="string2" value="${string1}"/> 
</c:forEach>

OTHER TIPS

You can try with replace function as:

    <c:set var="strng" value="SS4444"/>

    <c:set var="strng1" value="${fn:replace(strng,'S','')}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top