Regular Expression Exercises#

Section Title: Regular Expression Exercises

Question-1#

Separate and extract the digits from the following text: ‘I am 25 years old and my height is 180 cm.’

  • Output: [‘2’, ‘5’, ‘1’, ‘8’, ‘0’]

Question-2#

Extract the numbers from the following text: ‘I am 25 years old and my height is 180 cm.’

  • Output: [‘25’, ‘180’]

Question-3#

For the given states list, print the parts that include everything between ‘o’ and ‘a’.

states = ['Ohio', 'Florida', 'Iowa', 'Dakota', 'Arizona', 'Texas']

Question-4#

For the given states list, print the parts that include everything between ‘o’ and ‘a’, including ‘o’ and ‘a’ themselves.

states = ['Ohio', 'Florida', 'Iowa', 'Dakota', 'Arizona', 'Texas']

Question-5#

Extract the company name in the email part of the following text if it starts with ‘ID’.

text = 'ID=78243537282  email= abc@tesla.net 10/25/2001 12:59:34 pm'