Discuss Highlighting the patterns in the text in the Java Help forum on Dev Shed. Highlighting the patterns in the text Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
Time spent in forums: 44 m 7 sec
Reputation Power: 0
Highlighting the patterns in the text
I am working with strings.I have used apache poi 3.9 My program is matching a pattern in the string and then it gives the results in the form of highlighted text in the string to let the user know this pattern is found on this location in the string. The result file will be word document containing the string along with the highlighted portion. I have matched the patterns in the string and stored them in the array. But I am still at lost as to how shall I highlight the text. And there is problem also that matched patterns are in the array and each still be highlighted with different color which I do not know how to do.
Pattern p = Pattern.compile( strArray[j] );
while(m.find())//finding pattern in the sequence
patArray[inpat]=m.group();// stored match pattern in another array
This is my code for identifying patterns.
Please let me know or give me suggestion as to how I shall I highlight my patterns in the string.