Find all the numbers in a string using regular expression in Python
Given a string str containing numbers and alphabets, the task is to find all the numbers in str using regular expression.
Output: 11 15 678 4
Output: 1 133 0
Approach: The idea is to use Python re library to extract the sub-strings from the given string which match the pattern [0-9]+. This pattern will extract all the characters which match from 0 to 9 and the + sign indicates one or more occurrence of the continuous characters.
Below is the implementation of the above approach:
345 43 42