Wednesday, 8 November 2017

Javascript Regex Match whole words

var reg = new RegExp('\\b'+subquery+'\\b', 'gi');
        //var reg = new RegExp('\\b(' + subquery + ')\\b');
        var result;
        while((result = reg.exec(pageContent)) !== null) {
            matchesWithLength.push({
                        match: result.index,
                        matchLength: subqueryLen,
                        skipped: false
                      });
        }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.