s39674/Image2schematic

Replace complicated find() with Regex

Closed this issue · 0 comments

In PcbFunctions.py:

while(end_bracket_index != len(EBP_String)): # not really necessary
start_bracket_index = EBP_String.find("[", end_bracket_index)
middle_index = EBP_String.find(",", start_bracket_index)
# if not the +1 it would give the same position
end_bracket_index = EBP_String.find("]", end_bracket_index+1)
#print("start_bracket_index: ", start_bracket_index, " middle_index: ",
# middle_index, " end_bracket_index: ", end_bracket_index)
if (start_bracket_index == -1): # if not found
break
else:
EntireBoardPoints = np.append(
EntireBoardPoints, [[int(EBP_String[(start_bracket_index+1): (middle_index)]),
int(EBP_String[(middle_index+1): (end_bracket_index)])]], axis=0) # not sure why but this form works
return EBP_String, EntireBoardPoints

It basically just tries to find this form of text: [x,y]; Could someone write a simple regex to replace that?