Frage

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

War es hilfreich?

Lösung

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>

Andere Tipps

You can try with replace function as:

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

    <c:set var="strng1" value="${fn:replace(strng,'S','')}"/>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top