Thank you @serhii75
did not know this helper. Isn't laravel just the best! Was making my own way too often.
@jandk4014
Be very careful with this. Look for exact match and take into consideration spaces when replacing text with links
For example, if you want to link the word "trouble" and your text has the word "troublesome"
Also be sure to take care of Letter casing.
Be wary of pasting url links. They could transform the links if it contains your linked words.
One thing that also bothered me would be the performance hit. Every request and you need to transform this text.
I thought about doing that client side, in JS, but also costly in terms of performance, just transferred the responsibility.
What I would suggest to do is to have in your DB, a transformed text
for example
description and description_transformed
When you create/edit the article, you run the transform text service ONLY ONCE! Transform your text into links. Keep the original text for when you edit, you dont need to transform back without tags, but on the front end, output the transformed text only.