regex - Only match if surrounded by quotes -
this question has answer here:
i need match words of criteria, only if within quotes*. i'd wish via regex.
i think there's "jquery plugin that". google jquery basic arithmetic plugin.
let's have above text subject of regex search, , i'd wish find word "plugin", if inside quotes. not need match second "plugin" word @ end of sentence, since it's not within quotes, (edit) need match multiple occurrences of "plugin", enclosed quotes (even if there multiple occurrences inside single quotation block).
with working expression, following words (highlighted bold text) should matched:
i think there's "jquery plugin that". google jquery basic arithmetic plugin.
i have theoretical solution use positive lookahead determine if there or odd number of quotes, , match word if number odd.
what regular expression should use accomplish this?
*double quotes only
i use expression match words not surrounded quotes, following similar logic:
\bplugin\b(?=[^"]*(?:"[^"]*"[^"]*)*$)
Comments
Post a Comment