As I said before, I will strongly suggest to not to use RegEx for this and make use of HTML/XML parsers for parsing the tags and data and then do all your operations.
But if you don't want to do that for some reason then I would suggest you to fallback to the basic sub-string based methods rather than using RegEx
.
Here is a sample code snippet for the above situation:
public static void main(String[] args) {
String htmlFragment = "<span id=\"nav-askquestion\" style=\"width:200px;cursor:default;height:100px;\" name=\"questions\"> <b>hh</b></span>";
int startIndex = htmlFragment.indexOf("<span");
int stopIndex = htmlFragment.indexOf("</span>") + 7;
/* Cursor */
int cursorStart = htmlFragment.indexOf("cursor:", startIndex);
int cursorEnd = htmlFragment.indexOf(";", cursorStart);
htmlFragment = new StringBuilder()
.append(htmlFragment.substring(startIndex, cursorStart))
.append(htmlFragment.substring(cursorEnd + 1, stopIndex))
.toString();
/* Update Indices */
stopIndex = htmlFragment.indexOf("</span>") + 7;
/* Height */
int heightStart = htmlFragment.indexOf("height:", startIndex);
int heightEnd = htmlFragment.indexOf(";", heightStart);
htmlFragment = new StringBuilder()
.append(htmlFragment.substring(startIndex, heightStart))
.append(htmlFragment.substring(heightEnd + 1, stopIndex))
.toString();
/* Output */
System.out.println(htmlFragment);
}
I know it looks a bit messy but that's the only way I could think of.