Given a string that may contain a mix of letters, digits, spaces, and special characters, extract all sequences of consecutive digits and return them as a list of integers in the order they appear.

Return an empty list for null input or input with no digits.

Examples:

Input: input = 'abc 123 def 456' Output: [123, 456] Explanation: Two digit sequences found Input: input = 'Phone: 415-555-1234' Output: [415, 555, 1234] Explanation: Each hyphen-separated segment is a separate number Input: input = 'no numbers here' Output: [] Explanation: No digit sequences found Input: input = null Output: [] Input: input = 'the answer is 42' Output: [42]
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 All Time Leaderboard

Contest runs January 1, 1970 - December 31, 9999. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In