我正在编写代码来发现字符串的最左内索引(我正在做字符串解析)
下面的代码看起来正确吗?
String t = "VREF_DAC_BAND_GAP_(VALUE|DELTA|TRIM|K(7-0|15-9))"
int lb_ind = t.indexOf('(', 0); // left bracket index
int rb_ind = t.indexOf(')', lb_ind); //right bracket index
while((t.indexOf("(", lb_ind+1) != -1) && (t.indexOf("(", lb_ind+1) < rb_ind))
{
lb_ind = t.indexOf('(', lb_ind+1);
}
// lb_ind should now contain the position of the inner left most parenthesis