lsearch

lsearch [-all | -ascii | -exact | -glob | -not | -regexp | -start <index>] <list> <pattern>

This function returns the index of the first matching element in the specified <list>. It returns -1 if it does not find a match. Refer to the lsearch function on the Tcl Developer Xchange web site (www.tcl.tk) for a detailed explanaion of the options.

# Return the index of o12[1]
lsearch [get_nets [get_ports o12[*]]] {o12\[1\]}
lsearch –exact [get_nets [get_ports o12[*]]] o12[1]

# Return the index of the first element that is not o12[1]
lsearch -not -exact [get_nets [get_ports o12[*]]] o12[1]

# Return the indices of elements with the regex format o12\[.\]
lsearch -all -regexp [get_nets [get_ports o12[*]]] {o12\[.\]}