A Regular Expression to match all HTML tags

A regular expression to match all HTML tags, including surrounding white space, as well as clustered tags:


For example,  this can be used in java (or android) code to split an HTML table and return the contained text in each cell as members of an array of strings :

 String tablecontents [] = htmltable.split("(\\s*<[^>]+>\\s*)+");

This uses the string splitter function String.split(regexp) which can split strings based on a given regular expression.  The fragments are returned as an array, which is quite handy.