Hi!
I am trying to ease writing formulaes for myself with Java Latex API, but code soon starts to look very confusing. Therefore I would like to add highlighting of matching brackets to textArea, but have no idea how I would to that as efficiently as possible. Is it good if with every click onto text in textArea, I check the left or right sign according to carret's position, then go looking forward in text (backward if its inverse bracket) for a matching bracket? Im afraid that with long texts that would be disasterous. Thank you for any suggestions!
[IMG]http://shrani.si/f/45/11Z/36ZgVNLH/untitled.png[/IMG]
[IMG]http://shrani.si/f/2s/pD/1rmAMWiU/untitled.png[/IMG]
You should be able to highlight your code by using regular expressions. Here's a good link about it:
[url]http://www.vogella.com/articles/JavaRegularExpressions/article.html[/url]
And Wikipedia : [url]http://en.wikipedia.org/wiki/Regular_expression[/url]
[QUOTE=Swebonny;36332021]You should be able to highlight your code by using regular expressions. Here's a good link about it:
[url]http://www.vogella.com/articles/JavaRegularExpressions/article.html[/url]
And Wikipedia : [url]http://en.wikipedia.org/wiki/Regular_expression[/url][/QUOTE]
I don't think this is a problem that can be solved with regular expressions, as this is not a [i]regular[/i] problem. That's also why you can't parse HTML with RegEx.
[code]
depth = 0
for bracket after selected one:
if bracket is '{'
depth++
else
depth--
if depth == 0
// Found the matching bracket
[/code]
Sorry, you need to Log In to post a reply to this thread.