In my JSP, a hidden variable value shows as following.
<input type="hidden" name="" value="[1, 12, 2, 3, 4]" id="rollNumber"/>
When I try to get hidden variable in javascript function by document.getElementById and put it in a array (rollNo) as follows:
rollNo = document.getElementById("rollNumber").value;
rollNo value is coming as [1, 12, 2, 3, 4]
When I try to iterate rollNo it gives me elements as:
[
1
,
space
1
2
,
space etc... elements
I need only elements like '1 12 2 3 4'
you can do this by just using a simple regular expression
simple and elegant, is valid for all string containing digits, with any separators