Copy link to clipboard
Copied
I want to pick a string information inside of a bigger string (file name or folder name)
The string I want to pick is a 8 digit number (next to each other) and it can be some where in the middle of the big string.
For example:
Big string A:
_v_10097822-YVES.SAINT.LAURENT.273456YOD02.4176.Silk.15113
Big string B:
_v_nkld3sgrf10097822-YVES.SAINT.LAURENT.273456YOD02.4176.Silk.15113
I want to read always the 10097822
How can I do that with code in a function that returns the number I want?
You could try this..
var numberFromString = getNumbers("_v_nkld3sgrf10097822-YVES.SAINT.LAURENT.273456YOD02.4176.Silk.15113");
alert(numberFromString);
function getNumbers(str){
return str.match(/\d{8}/);
}
Copy link to clipboard
Copied
You could try this..
var numberFromString = getNumbers("_v_nkld3sgrf10097822-YVES.SAINT.LAURENT.273456YOD02.4176.Silk.15113");
alert(numberFromString);
function getNumbers(str){
return str.match(/\d{8}/);
}
Copy link to clipboard
Copied
Thanks!