We have the table Texts with the columns:

* wordcount (int)
* text (varchar 1024)

Currently wordcount is -1 in all the rows, but we would like to fill the column with these data:

* number of words in text, i.e. if text = "Hello Stackoverflow" => wordcount = 2
* if a word in the text is in a () or a [] it shouldn't count, i.e. "Hello to everyone on Stackoverflow" => wordcount = 5, but "Hello (to) everyone on Stackoverflow" => wordcount = 4 since (to) is in a ()

Anyone know how to write such an UPDATE query?