I have an application that matches certain words in long paragraphs.
The word can sometimes find it without an apostrophe, for example = "cant", but cannot find it when written as "can't" in a paragraph. So it can't match, how can i solve it?
There is only one of the apostrophes in the link below, but I also encounter this problem if there are sentences with = [' " ‘ ’] marked.
https://regex101.com/r/tsYuLH/1
my code block that matches words in paragraph:
this.highlightedText is my paragraph and element is my word that needs to be matched in the paragraph (I'm putting it in my span tag that I gave the background color, so it's matched.)
this.highlightedText = this.highlightedText.replace(new RegExp(element.split(".").join("\\.").split("+").join("\\+"), "g"),
`<span>${element}</span>`);
long story short, even if all the apostrophes of the regex I wrote come up, I expect my word to match.