how to extract a chord part and ignore the number in jquery?


I have a string like foobar1, foobaz2, barbar23, nobar100 I want only foobar, foobaz, barbar, nobar and ignoring the number part.

If you want to strip out things that are digits, a regex can do that for you:

var s = "foobar1";
s = s.replace(/\d/g, "");
// "foobar"

(\d is the regex class for "digit". We're replacing them with nothing.)

Note that as given, it will remove any digit anywhere in the string.