Javascript split numbers from string
Hi,
From time to time you have a string that contains numbers and letters and you need to split them.
This is very easy to do using Javascript.
Lets say you have thisĀ string:
var stringĀ = “due_date47″;
to create to vars that one will have “due_date” as value and the other “47″ do this:
<script type="text/javascript">var field = "due_date37";
var number=field.match(/\d/g).join('');
var nonnumber=field.match(/[^\d]/g).join('');
</script>
Easy!