Extract continuous number sequences from strings

Problem Given a list of strings containing letters and digits, extract every maximal run of consecutive digits from each string and return all such numbers.

Input / Output

  • Input: a string array, e.g. ["12A", "2VE3", "24"].
  • Output: a list of numbers in order of appearance, e.g. [12, 2, 3, 24].

Constraints

  • Runs can be multi-digit; watch leading zeros ("007" -> 7 or "007"? — clarify) and very long runs that overflow int (return as strings/BigInteger if so).

Example

  • ["12A", "2VE3", "24"] -> [12, 2, 3, 24]
  • ["a1b22c333"] -> [1, 22, 333]
asked …
LeaderboardSalaryAccount