if (!function_exists('ajaxSearchStripSnippets')) {
function ajaxSearchStripSnippets($string) {
$as = new AjaxSearchResults;
$string = $as->defaultStripOutput($string);
$string = preg_replace('~\[\[[^\]]*\]\]~is', '', $string);
$string = preg_replace('~\[\![^!]*\!\]~is', '', $string);
return $string;
}
}
Or maybe it is already there and I just don’t see it so in that case please help me, I will welcome any better solution

When a searchable document contains some snippets, then these snippets are normally displayed in ajaxSearch results (in so called "extracts").With AS 1.9.1, if you search something like "snip" and you have a content page with for instance [!Snippet!], then the sql search found this document.

and this "keyword" was just next to the snippet in the document, for example "keyword [!snippet!]". Then the extract contained something like "...keyword [!snipp...".I haven’t done this test, but the [!snippet!] call only will be remove. If the searchterm is near a snippet call, it should remain. The snippet call is parsed and stripped before to set up the extract.
I’ll definitely upgrade to 1.9.11.9.2 is coming in few days, so ...
The snippet call is parsed and stripped before to set up the extract.

This is new in 1.9.1?No. The code is the same for 1.9.0 and 1.9.1
$results = $this->_asRequest->doSearch();
$results = $this->_doFilter();
$this->_setSearchResults($site, $subsite, $results);_displayResults
_doFilter() {
...
$results = $this->_doFilterTags($results, $searchString, $advSearch);
...
} /*
* Filter the search results when the search terms are found inside HTML or MODx tags
*/
_doFilterTags(){
...
$text = $this->defaultStripOutput($text);
...
}
Probably I thought when I was reading it, that method stripTags only strips HTML tags, not also MODx tags. However I tested it again and the snippet tags were still displayed in search results. But I finally hopefully found where is the problem
It’s in the function stripTags.$modRegExArray[] = '~\[!(.*?)!\]~';
$modRegExArray[] = '~\[\![^!]*\!\]~is';


[!snippet? ¶m=`Hello world!`!]
~\[\!.+\!\]~Us

<?php
$text1= '[!snippet? ¶m=`Hello world!`!]';
$text1 = preg_replace('~\[!([^!]*)!\]~is', '', $text1);
echo "text1=".$text1;
echo "<br />";
$text2= '[!snippet? ¶m=`Hello world!`!]';
$text2 = preg_replace('~\[!(.*?)!\]~is', '', $text2);
echo "text2=".$text2;
echo "<br />";
$text3= '[!snippet?
¶m=`Hello world!`
!]
';
$text3 = preg_replace('~\[!(.*?)!\]~is', '', $text3);
echo "text3=".$text3;
echo "<br />";
$text4= '[!Snippet1? ¶m1=`xx` &id=`[!Snippet2!]` ¶m2=`zz`!]';
$text4 = preg_replace('~\[!(.*?)!\]~is', '', $text4);
echo "text4=".$text4;
echo "<br />";
?>
If I use ’~\[!(.*?)!\]~Us’, I remove all the snippets calls 
<?php
$text4= '[!Snippet1? ¶m1=`xx` &id=`[!Snippet2!]` ¶m2=`zz`!]';
$text4 = preg_replace('~\[!(.*?)!\]~Us', '', $text4);
echo "text4=".$text4;
echo "<br />";
$text5= '[!Snippet1? ¶m1=`xx`
&id=`[!Snippet2!]` ¶m2=`zz`!]
xxxxxxxxxxxxxxx
[!snippet3!]
';
$text5 = preg_replace('~\[!(.*?)!\]~Us', '', $text5);
echo "text5=".$text5;
echo "<br />";
?>