fork download
  1. import re
  2. list = '''Student name - Shaurya Ronak Ajmera
  3. Age - 7 years
  4. Std - 2nd
  5. Parents name - Ronak and Shital Ajmera
  6. Phone no - ******************
  7. Address - ***********
  8. Knows gujarati - can speak and understand. Reads and writes small sentences.
  9. Batch - 11 to 12:30 am'''
  10. numberRegex = re.compile(r'\d{10}')
  11. nameRegex = re.compile(r'student name - ([A-Za-z]+(?: [A-Za-z]+)*)', re.I)
  12. mo = nameRegex.findall(list)
  13. print(mo)
  14. no = numberRegex.findall(list)
  15. print(no)
Success #stdin #stdout 0.02s 9892KB
stdin
Standard input is empty
stdout
['Shaurya Ronak Ajmera']
[]