=== insource: ===

{{TNT|MW version|version=1.24|compact=y|comment=and after|gerrit change=137733}}
<translate>
<!--T:100-->
This can pick up template arguments, URLs, links, html, etc.</translate>
<translate>
<!--T:101-->
It has two forms. They both search the wikitext, but one is an indexed-based search, and the other is based on a regex search.
</translate>

{|class=wikitable style=background-color:white
|-
|<code>insource:word</code><br/><code>insource:"word1&nbsp;word2"</code>'''
|<translate><!--T:102-->
Like word searches and exact-phrase searches, non-alphanumeric characters are ignored, and proximity and fuzziness are options.</translate>
|-
|<code>insource:/''regexp''/</code><br/><code>insource:/''regexp''/i</code>
|<translate><!--T:104-->
These are [[w:Regular expression|Regular expressions]].</translate><translate><!--T:105-->
They aren't efficient, so we can only allow a few at a time on the search cluster, but they are very powerful.</translate><translate>
<!--T:106-->
The version with the extra <code>i</code> runs the expression case-insensitive, and is even less efficient.</translate>
|}

<translate>
<!--T:107-->
'''Tip:''' Instead of running a bare <kbd>insource:/''regexp''/</kbd>, these return ''much'' ''much'' faster when you limit the regexp search-domain to the results of one or more index-based searches.</translate>

*<translate><!--T:108-->
<tvar|1><code style="white-space:nowrap">insource:"<''tag''>{<nowiki/>{''template''}}<''tag''>" insource:<big>'''/'''</big><''tag''>{<nowiki/>{''template''}}</''tag''><big>'''/'''</big></code></></translate>
*<translate><!--T:109-->
<tvar|1><code style="white-space:nowrap">'''''other search terms''''' insource:"[<nowiki/>[''title''|''link label'']]'s" insource:<big>'''/'''</big>[<nowiki/>[''title''|''link label'']]'s<big>'''/'''</big></code></></translate>

*<translate><!--T:112-->
<tvar|1><code style="white-space:nowrap">insource:<big>'''/'''</big>''regexp''<big>'''/'''</big> '''prefix:{<nowiki/>{FULLPAGENAME}}'''</code></></translate>
*<translate><!--T:114-->
<tvar|1><code style="white-space:nowrap">insource:/self-absorbed/ '''prefix:user:''your-login-name'''''</code></></translate>

*<translate><!--T:116-->
<tvar|1><code style="white-space:nowrap">'''''namespace:''''' insource:"self-absorbed" insource:/self-absorbed/</code></></translate>
 
<translate>
<!--T:118-->
Any search without a namespace or prefix searches your default search domain, settable at ''[[Special:Search]]''. It is commonly reset by power users to ALL namespaces, but if this occurs for a bare regexp search, it will probably incur an HTML timeout.</translate>

<translate>
<!--T:119-->
Regex are character-wise per-page searches.
</translate>

<translate>
<!--T:120-->
All other search terms use an index. When using a regex, include other search terms to limit the regex search domain as much as possible.
</translate>

<translate>
<!--T:121-->
To develop a new regexp, or refine a complex regexp, use <code>prefix:{<nowiki/>{FULLPAGENAME}}</code> in any edit box. This limits the regexp search domain to the current pagename.  Use <code>prefix:User:''your-login-name''/</code> to test your regexp on a few pages.
</translate>
<span id=metacharacters></span>
<translate>
==== Metacharacters  ==== <!--T:122-->
The use of a regexp to search for an exact string that includes non-alphanumeric characters is a basic search.
It finds regular expression metacharacters literally, but you must "escape" them, usually one at a time with a backslash <code>\</code>.</translate>
<translate>
<!--T:123-->
For example <code>insource:/\[123\-125\]\.</code>/ matches a literal dash, dot, or square bracket.</translate>
<translate>
<!--T:124-->
But you can also safely "quote" any characters using double-quotes inside a regexp and this will neutralize all metacharacter meaning to perform a basic, exact-string search: <code>insource:/"[123-125]."</code></translate>

<translate>
<!--T:125-->
Inside double quotes you ''must'' use backslash-escape to escape the double-quote character, for example <code>"A literal \" character"</code>.</translate>

<translate>
<!--T:126-->
Inside the regexp you ''must'' use the backslash-escape to quote the slash character that is the closing delimiter.</translate>

<translate>
<!--T:127-->
The square-bracket notation (for creating your own character-class) also escapes metacharacters.</translate>

<translate>
<!--T:128-->
You can escape any metacharacter that happens to be included, except that the right square bracket must be escaped or a dash must be backslash escaped. them as just shown, or just the first position can be used: <code>[-.\]]</code> or <code>[].\-]</code>, either of which match a dot, dash or right square bracket.</translate>

<translate>
<!--T:129-->
For the actual meaning of the metacharacters see the [<tvar|link1>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-syntax</> explanation of the syntax].</translate>

<translate>
<!--T:130-->
For the formal definition see the [<tvar|link2>http://lucene.apache.org/core/4_8_1/core/org/apache/lucene/util/automaton/RegExp.html</> Lucene grammar for regular expressions]. </translate>

<translate>
<!--T:131-->
For example, using metacharacters to find the usage of a template called ''Val'' having, inside the template call, an unnamed parameter containing a possibly signed, three to four digit number, possibly surrounded by space characters, AND on the same page, inside a template Val call, a named argument "fmt=commas" having any allowable spaces around it, (it could be the same template call, or a separate one):</translate>

:<code>hastemplate:val insource:"fmt commas" insource:<big>'''/'''</big>\{\{val\|[^}]*fmt *= *commas/ insource:/\{val\| *[-+]?[0-9]{3,4} *[|}]<big>'''/'''</big></code>

<translate>
<!--T:132-->
It is fast because it uses two filters so that every page the regexp crawls has the highest possible potential.</translate>

<translate>
<!--T:133-->
Assuming your search domain is set to ALL, it searches the entire wiki, because it offers no namespace or prefix.</translate>