Another slightly different take:
first1 =: 2 </\0,]
mask =: 0 0,2*./\2=/\]
span =: ((a:,<'</span>'){~(first1&.|.)),:(a:,<'<span>'){~first1
;|:2 0 1{(<"0,span&mask)t
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
