Skip to content

word unicode boundary match #85

@jomart-1985

Description

@jomart-1985

hi i need way to ignore groups in regex for example in modern browser which support Positive lookbehind
i can simply do this in regex find pattern with word boundary :

pattern = XRegExp("(?<=[\s\p{P}\p{S}]|^)("+words+")(?=[\s\p{P}\p{S}]|$)", "g");

findAndReplaceDOMText($($jQueryObject2).find('.pagebody').get( 0 ), {
find: pattern,
replace: function(portion, match) {

				var el = document.createElement('mark');
                                   el.classList.add("mark");

				el.innerHTML = portion.text;
	
				return el;
			}
      }); 

the issue with this start group boundary :
(?<=[\s\p{P}\p{S}]|^)
its not supported with old browser so i use alternative like this:
pattern = XRegExp("(^|[\s\p{P}\p{S}])("+term+")(?=[\s\p{P}\p{S}]|$)", "g");

but that will also capture first group which i don't want so how can i ignore first group in this pattern:
(^|[\s\p{P}\p{S}])("+term+")(?=[\s\p{P}\p{S}]|$)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions