This is about parsing inline CSS style properties of HTML. I'm using JSoup but so far as I'm able to ascertain JSoup has chosen not to help with this... I'm not sure why. It means that the users have to find out the rules for legal characters in keys and values, etc., i.e. what constitutes "properly formed" CSS style "attributes" (is this even the correct term? [later: no! style "properties", according to CSSParser]).
Anyway, what I want to do, in extracting each individual key-value pair, is to divide them up by semicolon... but in the last pair the trailing semicolon is optional. However, allowing for white space it will end with the end of the String.
So I tried this:
Pattern styleSubattrsPattern = Pattern.compile( "([A-Za-z0-9-]+)\\s*:\\s*([A-Za-z0-9-]+)\\s*[$;]");
... meant to mean "either a semicolon OR the end of the String". But it doesn't work: the final key-value pair is not matched.
later
The root problem was indeed solved by using CSSParser.