Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.2K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Extract a number from a string

Posted 11 years ago
POSTED BY: Bruce Colletti
4 Replies
Posted 11 years ago

Bill, this is shorter and thus better -- didn't think of using RegularExpression. Girish provided the solution I hoped was out there, and both replies are useful. Thanks.

POSTED BY: Bruce Colletti
Posted 11 years ago

Girish, this is perfect, exactly what I sought. Thanks.

POSTED BY: Bruce Colletti
Posted 11 years ago

You can also try--

StringSplit[x][[2]] // ToExpression
POSTED BY: Girish Arabale
Posted 11 years ago

Is this simpler?

n = StringReplace[x, RegularExpression["\\D+"] -> " "] // ToExpression

which will handle any non-digit characters before and/or after the digits, but won't handle several groups of digits.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard