Bold words from imported text

I’d like to import text from a file to a text area and bold particular words. Fairly straightforward to put raw text into a text area. But can I format specific words?

https://documentation.xojo.com/api/text/styledtext.html is your friend (at the moment), it might become your enemy ;-).

Basically have a list of all the words to make bold
Find them with either InStr or RegEx (make sure you get the whole word - if you want to replace all mentions of rat with mouse then you don’t want to end up with bmouse)
Set the style of the found word

This old project finds every occurrence of bit bat but in the text - should get you on your way:

1 Like