// say you wanted to collect all the chars before a slash (/). myString = "12345.67890"; newString = myString.substring(0, myString.indexOf('/')); console.log(newString); // returns "12345"