I want to stylise the text.
Don’t bother, I got it thanks.
I have a string being passed to me which I have to highlight.
Not sure what you mean here? You can store strings in variables as normal
like I want this text to be dynamic such that I don’t have to write the whole expression separately for each of them. Is there any regex that we could use to wrap up the text within the required expression?
It’s a string so you can do whatever you like that you can do with a string. I’m not exactly sure what you are asking here?
Can you give a clear example?
this seems working well ‘[color="#ff0000"]text[/color]’
but when I am doing as follows the output is “myText” in red colour.
let myText = “hello world”;
using ‘[color="#ff0000"]myText[/color]’
Is there a way we could sort it out?
Still not sure what you are asking?
let myText = "hello world";
this.element.text = '[color="#ff0000"]' + myText + '[/color]';
Is this what you are asking?
Yes apparently it seems to be an easy string append. Don’t know what I was thinking there with regex. Sorry to bother you.