I have a complete html file input as string(I have file also) in java. Text is something like below
Sample input
    Some text........... <s:message code="code1" arguments="${arg1,arg2}" />..
    some text  ........
    some text  ....... <s:message code="code2" 
     />...........
Basically I need to replace all text based on code type. For example if code is code1 then replace the s:message tag with test1
sample output
    Some text........... test1..
    some text  ........
    some text  ....... test2 ...........
I am not getting how to capture complete <s:message  > and then replace it with some other text ? Looks like i need to use regex here but
not getting how to start ?
Update :-
code1 and test1 are just examples and they can be any value. code1 can be xyz and can be replaced by abc. That's why i want to capture all message tags(either one by one while traversing or in one go) ,then get the code , do some logic and see what will be the replacement value.
Approach 2:- There is another way I can do it, I have list of codes in data structure, For each code check if there is in any enclosing message tag, capture it and then process it.