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

Était-ce utile?

La 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>

Autres conseils

You can try with replace function as:

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

    <c:set var="strng1" value="${fn:replace(strng,'S','')}"/>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top