文字列から英数字ではない文字を削除します
次の文字列を提供された出力に変換したい。 Input: "\\test\red\bob\fred\new" Output: "testredbobfrednew" 私のような特殊文字が処理する任意の解決策が見つからないてきました\r、\n、\b、など 基本的に、英数字以外のものはすべて削除したいだけです。これが私が試したものです... Attempt 1: "\\test\red\bob\fred\new".replace(/[_\W]+/g, ""); Output 1: "testedobredew" Attempt 2: "\\test\red\bob\fred\new".replace(/['`~!@#$%^&*()_|+-=?;:'",.<>\{\}\[\]\\\/]/gi, ""); Output 2: "testedobred [newline] ew" Attempt 3: "\\test\red\bob\fred\new".replace(/[^a-zA-Z0-9]/, ""); Output 3: "testedobred [newline] ew" Attempt 4: "\\test\red\bob\fred\new".replace(/[^a-z0-9\s]/gi, ''); Output 4: "testedobred [newline] ew" 複数のステップでのもう1つの試み function cleanID(id) { id = id.toUpperCase(); id = …