1. First Method to remove operators:
'123+456-321'.split(/([-+\/*])/) // gives == ["123", "+", "456", "-", "321"]
2. Second Method to remove operators:
<script type="text/javascript">
var strIn = '123+456-321';
var tarrN = strIn.split(/\D/);
var tarrO = strIn.split(/\+|\-|\*|\//);
alert(tarrN.join('\n')+'\n\n'+tarrO.join('\n'));
</script>
0 comments:
Post a Comment