3

The documentation has the following example to find all runs in a string containing only "a" and "b":

StringCases["aababbcccdbaa", ("a" | "b") ..]
{"aababb", "baa"}

I would like to find all runs in a string containing only numbers. E.g.,

findnumbers["DataSummary_1N_5M_10L.dat"]
{"1", "5", "10"}

What is the nice way to do this, besides just writing out explicitly in the second argument of StringCases ("1" | "2" | "3" | "4" |...etc... ) ..? Thanks!

Diffycue
  • 1,834
  • 8
  • 11

1 Answers1

5
data = "DataSummary_1N_5M_10L.dat";

StringCases[data, NumberString]

{"1", "5", "10"}

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
eldo
  • 67,911
  • 5
  • 60
  • 168