Here is the function you wished for.
I put some extra variables inside this function, so it is easier for you to enhance it.
(defun sum-the-brackets (begin end)
"sums up values in brackets with style '[ FLOAT u ]'
For non interactive use BEGIN must be smaller then END.
If FLOAT is omitted bracket counts with value one
If FLOAT is '.' it counts as value 0
Whitespace inside the brackets is ignored"
(interactive "r")
(save-excursion
(let ((n 0) ; desired value
(c 0) ; counter
(tmp nil) ; string in bracket
(tmpf 0)) ; value of string in bracket
(goto-char begin)
(while (search-forward-regexp "\\[ *\\([0-9]*\\.?[0-9]*\\) *\\(u *\\)\\]" end t)
(setq c (1+ c))
(setq tmp (match-string 1))
(setq tmpf (if (string= "" tmp) 1
(string-to-number tmp)))
(setq n (+ n tmpf)))
(message "Sum-Value: %2.3f ; brackets counted: %d" n c))))
This function sums up following 6 brackets to value 3.6:
Here is some text. [0.1u]
Here is some more text [ 0.2 u]
count me with value zero point 3 [.3 u]
count me with value two [2 u]
count me with value one [u]
count me with zero [ . u ]
And here is some noise: 0.2
Note: politza answer is way more cool. :)
Note2: comments/edits on improvement of the code are very welcome, I did code this for practice and it took me a while. :)
Edit: the user "jch" changed the question. I will not update this answer because "jch" gave an answer which fits his edits and maybe someone else finds my answer useful.