You are not logged in. Please login at www.codechef.com to post your questions!

×

How to extract all numbers from a string in java?

How to extract all numbers from a string in java?

asked 02 Oct '17, 13:54

pandey_96's gravatar image

1★pandey_96
667
accept rate: 0%


Suppose the String is n then array s will contain all the numbers present in the String

String n=sc.next();

String[] s = n.split("[a-zA-Z]+");

eg n="abc1defghi23jvkfbd57jnfbddj9"

then s will be

1,23,57,9

link

answered 02 Oct '17, 13:57

spp____'s gravatar image

2★spp____
1.1k211
accept rate: 9%

Answer is hidden as author is suspended. Click here to view.

answered 02 Oct '17, 14:32

raj79's gravatar image

2★raj79
(suspended)
accept rate: 10%

edited 02 Oct '17, 14:32

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×643

question asked: 02 Oct '17, 13:54

question was seen: 492 times

last updated: 02 Oct '17, 14:32