How can I improve the following regex to effectively search for C, CLK, and CE ports and specific printing associated on that ports?
Right now code below detects C, CLK and CE but are all labeled as C port, which is not intended.
Sample code below:
import re
test_array = ['jclk','jce','ja','jb','jc','jd','je']
for thisEntry in test_array:
if re.match(r'jc', thisEntry):
print("this is C port")
elif re.match(r'jce', thisEntry):
print("this is CE port")
elif re.match(r'jclk', thisEntry):
print("this is CLK port")
else:
print("dont care")
Result:
this is C port #for 'jclk', incorrect
this is C port #for 'jce', incorrect
dont care #for 'ja', correct
dont care #for 'jb', correct
this is C port #for 'jc', correct
dont care #for 'jd', correct
dont care #for 'je', correct
Thanks in advance.