var someString = "A04.3 A new Code"; var index = someString.indexOf(" "); // Gets the first index where a space occours var id = someString.substr(0, index); // Gets the first part var text = someString.substr(index + 1); // Gets the text part