Pergunta

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

Foi útil?

Solução

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>

Outras dicas

You can try with replace function as:

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

    <c:set var="strng1" value="${fn:replace(strng,'S','')}"/>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top