bracketPos

Returns index of closing/openinig bracket of the provided bracket

T is data type of each element (usually char in case of searching in strings) forward if true, then the search is in forward direction, i.e, the closing bracket is searched for opening is the array of elements that are to be considered as opening brackets closing is the array of elements that are to be considered as closing brackets. Must be in same order as opening s is the array to search in index is the index of the opposite bracket

bracketPos
(
T
bool forward = true
)
(
T[] s
,,
T[] opening = ['[', '{', '(']
,
T[] closing = [']', '}', ')']
)

Return Value

Type: uinteger

index of closing/opening bracket

Throws

Exception if the bracket is not found

Examples

assert ((cast(char[])"hello(asdf[asdf])").bracketPos(5) == 16);
assert ((cast(char[])"hello(asdf[asdf])").bracketPos(10) == 15);

Meta