I'm trying to add a character limit clause to this white list regex approach
str = str.replace(/[^A-Za-z-_0-9 ]/g, "");
Is it possible and how do I do it?
str = str.replace(/[^A-Za-z-_0-9\s]/g, "").substring(0,10); //At most 10 chars