Menu
Is there a regular expression that will split a string between operands like +, -, * or /
similar to the following attempt that only partially works?
[code]
<script type=”text/javascript”>
var strIn = ‘123+456-321’;
var tarrN = strIn.split(/D/);
var tarrO = strIn.split(/+|-|*|//);
alert(tarrN.join(‘n’)+’nn’+tarrO.join(‘n’));
</script>
Both give the same results. They split on the numbers, but loses the operators.
I was trying for an output of:
[code]
123
456
321
+
–