Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

How can javascript extract number from string?

Asked by Neeraj Thakur Oct 12, 2022 776 views 1 answer
Share

About this question

 Consider the following string in [removed]

var string="border-radius:90px 20px 30px 40px";

I want to extract the 4 numbers from that string and store them in an array called numbers.To do that I developed the following code:

var numbers=string.split("border-radius:");

numbers=numbers[1].split("px");

This code is working fine but I was wondering if there is a better approach/solution.

Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.