Text matching based on a list/array ?
I'm currently using an excel sheet to do something I'd really rather do on my website. I'm wondering if this can be done in Java perhaps?
I need to be able to paste in a block of text (to a text area field perhaps) and have that text compared to a list of items. I want to have it output the original text but highlight the parts that match something in the list.
I suspect I can use an array for the list but I have no idea how to get it to search for, and highlight the text.
Re: Text matching based on a list/array ?
The String class has several methods you can use to help you search. The methods: contains, indexOf, substring and length come to mind.
Re: Text matching based on a list/array ?
Highlight where?
Are we talking in HTML?
In which case String has a replaceAll() method ... which you would know if you had looked at the API, and that's a skill you really need to pick up.
Replace the String with itself wrapped in whatever mark up is needed to priduce a highlight...and that's HTML, so not really relevant to here.