in reply to Extraction of numbers in an string
There are at least 42 ways.
Please show what you've tried, and how it didn't work. You might be close!
Edit: OK, thanks for your code.
If you just want to extract numbers, you could use a simple regular expression instead of split() (which you would have to call more than once to get your desired results from your string):
Note the use of g to match all occurrences, and a to force the regexp to match only ASCII numbers with the /d character class.my @x = ( $string =~ /\d+/ga );
You should familiarize yourself with the basics of regular expressions: perlrequick is a good place to start.
Finally, may I ask why your data is in this format? It smells like an XY problem and there are probably better ways to create your input data. What is the task you are really trying to accomplish?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Etxraction of numbers in an array
by t-rex (Scribe) on Nov 24, 2016 at 13:13 UTC |