I am still new on regex (I should learn), I just need JS regex to extract string and number from a text like this: [number][string].
( /^(\d+).(\s+)/?)
Any help please?
I think you are looking for '/\d+[a-z]+/gi' :
var x = "123123K, 333D".match(/\d+[a-z]+/gi);
console.log(x); //["123123K", "333D"]
UPDATE: x is array. You can iterate over it and extract number and text:
xitem.match(/\d+/)[0] //number
xitem.match(/[a-z]+/i)[0] //text
P.S.: About \s:
Matches a whitespace character, which in ASCII are tab, line feed, form feed, carriage return, and space; in Unicode, also matches no-break spaces, next line, and the variable-width spaces (amongst others).
/\d+[a-z]+/gi regexp matching "D123" and "1D1D1" can't be in matched pieces.All pieces are of "{number}{text}" kind.If the square brackets are in the line as well then do the following:
/^\[(\d+)\]\[(\s+)\]$/
If they are not
/^(\d+)(\s+)$/
textyou need to extract from?