0

My question is how to make the three steps I use into one step; how do I combine these to just one?

Thank you!

var string = "1.4 Whatever";
var a = string.replace(/[0-9]/g,'');
var b = a.replace(/[\.]/g, '');
var c = b.replace(/ /g, '');

console.log(c);

3
  • 2
    [0-9. ] matches any digit or . or a space. Commented Apr 7, 2018 at 13:34
  • Thanks Pointy. Superfast! Commented Apr 7, 2018 at 13:35
  • you just trying to remove 1.4? Commented Apr 7, 2018 at 13:37

1 Answer 1

1

Just like this

var string = "1.4 Whatever";
var a = string.replace(/[0-9\. ]/g,'');

console.log(a);

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.