In a string of characters, how to extract this string of characters with JS,
Such as xxxxxx1111; know the length of xxxxxx, extract xxxxxx and 1111 respectively, prawn help
javascript: var s = "xxxxxx1111"; var sm = s.match (/ x * /); var sm_s = sm.index; var sm_l = sm.lastIndex; var si = sm.input; alert (si.substring (sm_s , sm_l) + sm_l + si.substring (sm_l, si.length)); void (0)
Just run it in the browser and you have the answer
You can use regular expressions
var str = "aaaaaaaa1111";
var test = /([a-zA-Z]{8})([0-9]{4})/
Then extract Group 1 and Group 2 separately, you can go to Google to find out how to achieve it. This is faster and better than substring in speed.