Hey everyone, I'm new here and grateful to have found this forum. Thank you "stackoverflow" and all of you for this amazing opportunity.
I've encountered a problem. How can I pass a variable to a regular expression in order to split it?
Here's what I have:
var text = "I am new to the forum";
var term = "TO";
var textSplit = text.split(/term/gi);
What I want to achieve is to pass the variable "term" to the regular expression so that it divides if there's no match, but I'm unsure how to do it. Any better ideas or suggestions would be greatly appreciated.
Thank you in advance!