I have an html code saved in a database. I want to convert specific words (for example: school, books, chock) into links ( tags) and I want the conversion to be safe.
One possible way to do that is to strip all tags first, so that I will not add a link where it is not supposed to be. But in this case I will loose the formatting and I don't want that.
To clarify the problem I will show you some examples for a problematic code, where an error will occur if I try to change "books" into "books:
1. <div class="books">lorem ipsum dolor....
2. <a href = "http://www.example.com">all of the books in the store</a>
Thanks in advance!