"?(огурец)[^><\s'"]*(?:"(?=[^>]*<\/))?(?:"(?![^>]*>))?(?:(?!(?:\s*<[^Aa][^>]*>\s*[^<>]*)*[^>]*(?:<\/a>)|(?:[^"'>]*["'][^>]*>))|(?=[^>]*(?:<a\s)))
"?(огурец)("(?=[^>]*<\/))?("(?![^>]*>))?(?:(?!(?:\s*<[^Aa][^>]*>\s*[^<>]*)*[^>]*(?:<\/a>)|(?:[^"'>]*["'][^>]*>))|(?=[^>]*(?:<a\s)))
"?(огурец)("(?![^>]*>))?(?:(?!(?:\s*<[^Aa][^>]*>\s*[^<>]*)*[^>]*(?:<\/a>)|(?:[^"'>]*["'][^>]*>))|(?=[^>]*(?:<a\s)))
"?(огурец)("(?![^>]*>))?(?:(?![^>]*(?:<\/a>)|(?:".*>))|(?=[^>]*(?:<a\s)))
"?(огурец)"?(?:(?![^>]*(?:<\/a>)|(?:".*>))|(?=[^>]*(?:<a\s)))
(огурец)(?:(?![^>]*(?:<\/a>)|(?:".*>))|(?=[^>]*(?:<a\s)))
(search)(?:(?!.*(?:<\/a>)|(?:".*>))|(?=[^>]*(?:<a\s)))
"?(огурец)[^><\s'"]*(?:"(?=[^>]*<\/))?(?:"(?![^>]*>))?(?:(?!(?:\s*<[^Aa][^>]*>\s*[^<>]*)*[^>]*(?:<\/a>)|(?:[^"'>]*["'][^>]*>))|(?=[^>]*(?:<a\s))|(?=(?:[^"'>]*["'][^>]*<)))
1) regexr.com?3151r