How to checks for a match at the beginning of a string in MULTILINE mode using regex in Python

1 Answer

0 votes
import re

s = re.search('^ja', 'python\njava\nphp', re.MULTILINE)  

if s:
  print('found:', s.group())
else:
  print('not find')


 
 
   
'''
run:
   
found: ja
   
'''

 



answered Aug 1, 2019 by avibootz
...