Вопрос

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

Это было полезно?

Решение

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>

Другие советы

You can try with replace function as:

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

    <c:set var="strng1" value="${fn:replace(strng,'S','')}"/>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top