• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extracting numbers from string  RSS feed

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I would like to know if it is posible to extract only numbers from a string

example: "hello-12world"

how can i read only 12 from the above string.

there is no fixed index for the string
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way is probably to use regular expressions. If you are not comfortable with regex, and hence, not easy for you, you can uses the string support methods, such as charAt(), indexOf(), substring(), etc.

Henry
 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks the reply..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!