Skip to content

Commit bf74a64

Browse files
authored
fix: regex to find words around expressions (#690)
1 parent a71c456 commit bf74a64

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

browser-extension/plugin/src/transform-general.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function locateSlur(uliStore, targetWords) {
134134

135135
const escapedTargetWord = targetWord.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
136136
// regex for multi-word and single-word phrases
137-
const regex = new RegExp(`(^|\\s|[.,!?])(${escapedTargetWord})(?=\\s|$|[.,!?])`, 'giu');
137+
const regex = new RegExp(`(^|[\\s.,!?()'"\\[\\]{}<>;:@#\\$%\\^&*+=~_“”‘’])(${escapedTargetWord})(?=[\\s.,!?()'"\\[\\]{}<>;:@#\\$%\\^&*+=~_“”‘’]|$)`, 'giu');
138138

139139
if (regex.test(tempParent.textContent)) {
140140
tempParent.innerHTML = tempParent.innerHTML.replace(regex, (match, prefix, word) => {

0 commit comments

Comments
 (0)