I’m having trouble accomplishing a few things with my program, I’m hoping someone is able to help out.
I have a String containing the source code of a HTML page.
What I would like to do is extract all instances of the following HTML and place it in an array:
<img src="http://*" alt="*" style="max-width:460px;">
So I would then have an array of X size containing values similar to the above, obviously with the src and alt attributes updated.
Is this possible? I know there are XML parsers, but the formatting is ALWAYS the same.
Any help would be greatly appreciated.
I’ll suggest using
ArrayListinstead of a static array since it looks like you don’t know how many matches you are going to have.Also not good idea to have REGEX for HTML but if you are sure the tags always use the same format then I’ll recommend:
Here is an example: