-2

I have a string like %B~7566952, and I want a regular expression that can be applied to replace it to get B7566952, so a regular expression that takes non-alphanumeric characters and deletes them.

1

1 Answer 1

0

var str = "%B~7566952";
document.write(str.replace(/[^a-zA-Z0-9]/g, ""));

Sign up to request clarification or add additional context in comments.

1 Comment

str.replace(/\W/g, '') is equivalent (well nearly, as the underscore character is in W but not in your expression)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.