From the following markup.
<div id="my-div"> <a href="#" id="link-1">Somewhere</a> <a href="#" id="link-2">Somewhere else</a> </div>
My text:
var str = 'Cost USD 400.00';
I have following code snippet:
var reg = /^[0-9]$/; $('input[type="text"]').keypress(function(){ console.log(reg.test(parseInt($(this).val()))); });
Given a string like: #/projects/58/tasks/140 I want to be able to extract 58 & 140. I have the following:
parseInt(hash.match(/\d+/)[0]);
parseInt(hash.match(/\d+/)[1])
I have a string which is of format ABC1234567
var value = "ABC1234567" var first3Letters = value.substring(0,3); // ABC var next7Letters = value.substring(3,7); //1234567`