K
Kevin Potter
I have a string, that I need to find the first occurance of a
particular known character in ("index" comes to mind), but with a
twist.
The problem is, I need to find the first occurance of this character
that is not enclosed in brackets "[]" in this string.
Example string:
"abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz".
How can I find the POSITION number of the first occurance of the
letter "x" that is not enclosed in the bracketed text (the one I want
is the one directly before the capital YZ).
I've tried numerous versions indexing this and that, comparing this to
the positions of the first and successive brackets, but cannot come up
with a realiable method.
Any thoughts, or pointers would be really appreciated. Maybe a fancy
regex would be able to do this?
particular known character in ("index" comes to mind), but with a
twist.
The problem is, I need to find the first occurance of this character
that is not enclosed in brackets "[]" in this string.
Example string:
"abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz".
How can I find the POSITION number of the first occurance of the
letter "x" that is not enclosed in the bracketed text (the one I want
is the one directly before the capital YZ).
I've tried numerous versions indexing this and that, comparing this to
the positions of the first and successive brackets, but cannot come up
with a realiable method.
Any thoughts, or pointers would be really appreciated. Maybe a fancy
regex would be able to do this?