Suppose there is a String array called "myStringArray" and it is passed to a method called "myTestMethod".
Suppose this String array has the following values:
myStringArray = "Arial;Arial;Greetings";
myStringArray = "<strong>My name is John Doe</strong>";
I would like to set the String array called "text" equal to the values of the String array "myStringArray", but I don't want the String array "text" to have the font names and the xml tags.
In other words, I would like "text" to have these values:
text = "Greetings";
text = "My name is John Doe";
How can I do this? Below is the code I have written so far.
The substring() method might work, but you will have to work out the indices to split on. You will have to look for semicolons, angle signs, etc. The whole thing looks error‑prone to me. You would have similar problems with String#split(), even if you already know how to write the appropriate regular expressions.
These two words in the same sentence should always cause a knee-jerk reaction that is strong enough to topple the desk you're sitting at.
NEVER combine XML and regular expressions. You simply can not process XML well with regular expressions because XML is not a regular language, but another type of context-free language. For every regular expression that you write to process XML in a certain way, I can write a piece of XML for which it will fail.
Your first suggestion was the right way to go: Use an XML processor to process XML.