D
David
Hi Everyone,
I'm looking for a way to grab a number from a string, although this number
is not at either end of the string.
Here is the string in question: var el = "v4Function_Name('argument3')"
Here is a substring that returns the number ( the 3 ) successfully...
var number = el.substring(el.lastIndexOf("ent")+3,el.length-2);
Seems very ineffecient to do it this way, and better to find a lean elegant
way using replace(); How does one go about getting a value inside of a
string with regular expressions? .. or is there a better way?
Here are a couple of the many expressions I have failed with...
var pat = /^[^ent][0-9]*$"/;
var pat = /v4Function_Name\('argument([^0-9]+)'/;
var number = el.replace(pat,"");
David
I'm looking for a way to grab a number from a string, although this number
is not at either end of the string.
Here is the string in question: var el = "v4Function_Name('argument3')"
Here is a substring that returns the number ( the 3 ) successfully...
var number = el.substring(el.lastIndexOf("ent")+3,el.length-2);
Seems very ineffecient to do it this way, and better to find a lean elegant
way using replace(); How does one go about getting a value inside of a
string with regular expressions? .. or is there a better way?
Here are a couple of the many expressions I have failed with...
var pat = /^[^ent][0-9]*$"/;
var pat = /v4Function_Name\('argument([^0-9]+)'/;
var number = el.replace(pat,"");
David