<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AStrloc_prefix</id>
	<title>Template:Strloc prefix - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AStrloc_prefix"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Template:Strloc_prefix&amp;action=history"/>
	<updated>2026-07-20T03:18:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Template:Strloc_prefix&amp;diff=21177&amp;oldid=prev</id>
		<title>JChris.FillionR: Created page with '&lt;includeonly&gt;&lt;!-- -============================================================= - Strloc_prefix - Get prefix up to strloc or entire string -=====================================…'</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Template:Strloc_prefix&amp;diff=21177&amp;oldid=prev"/>
		<updated>2011-08-25T06:14:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;includeonly&amp;gt;&amp;lt;!-- -============================================================= - Strloc_prefix - Get prefix up to strloc or entire string -=====================================…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;includeonly&amp;gt;&amp;lt;!--&lt;br /&gt;
-=============================================================&lt;br /&gt;
- Strloc_prefix - Get prefix up to strloc or entire string&lt;br /&gt;
-=============================================================&lt;br /&gt;
--                              (see NOTES at bottom)&lt;br /&gt;
--&amp;gt;{{#ifexpr: {{{strloc|7}}} &amp;gt; 0&lt;br /&gt;
  | {{padleft:|{{#expr:{{{strloc|7}}} }}|{{{1}}}}}&lt;br /&gt;
  | {{{1}}}&amp;lt;!--too long or strloc &amp;lt;= 0 (string not found) --&amp;gt;&lt;br /&gt;
}}&amp;lt;noinclude&amp;gt;&amp;lt;!--&lt;br /&gt;
--------------------------------------------------------------&lt;br /&gt;
--NOTES&lt;br /&gt;
--&lt;br /&gt;
-- NOTE A1: This template gets the prefix of a string up to&lt;br /&gt;
--      length strloc, or the entire string when strloc &amp;lt;= 0.&lt;br /&gt;
--      It allows the location strloc to be a variable amount&lt;br /&gt;
--      such as the result of a string search, because strloc&lt;br /&gt;
--      is used twice: once to check if the entire string will&lt;br /&gt;
--      be the result, or a 2nd time to limit the length of&lt;br /&gt;
--      string extracted to length strloc. Hence, if strloc is&lt;br /&gt;
--      set by a complex search or formula, then the use of&lt;br /&gt;
--      this template will be about twice as fast as coding the&lt;br /&gt;
--      logic directly.&lt;br /&gt;
--&lt;br /&gt;
-- NOTE N2: The expansion depth of this template is 2 levels,&lt;br /&gt;
--      with 1 level for being a template, and the 2nd level&lt;br /&gt;
--      needed to check the value of length strloc.&lt;br /&gt;
--&lt;br /&gt;
--------------------------------------------------------------&lt;br /&gt;
--HISTORY:&lt;br /&gt;
--07Feb2011 Created for string-prefix copy 2x times as fast.&lt;br /&gt;
--&amp;gt;&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Source: http://en.wikipedia.org/wiki/Template:Strloc_prefix&lt;br /&gt;
&lt;br /&gt;
The string-prefixer '''[[Template:Strloc_prefix]]''' gets the prefix of a string up to a specified location, or the entire string when location is less than 1.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
::: {&amp;amp;#123;'''Strloc prefix'''|&amp;lt;string1&amp;gt;|strloc=&amp;lt;n&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Returns the prefix of ''string1'' up to location strloc=''n'', where ''n'' = 1 denotes the first character of the string. If ''strloc'' &amp;lt;= 0 then the entire ''string1'' is the result. The parameter ''strloc'' can be a math formula, such as: strloc={{{len}}}-2, or strloc=abs(-2*5)+6.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
The following show various uses:&lt;br /&gt;
:* {&amp;amp;#123;Strloc prefix|abcdef|strloc=3}}{{pad|2em}}&amp;amp;rarr; {{Strloc prefix|abcdef|strloc=3}}&lt;br /&gt;
:* {&amp;amp;#123;Strloc prefix|abcdef|strloc=0}}{{pad|2em}}&amp;amp;rarr; {{Strloc prefix|abcdef|strloc=0}}&lt;br /&gt;
:* &amp;lt;nowiki&amp;gt;{{Strloc prefix|My Title (film)|strloc= {{strfind_short|My Title (film)|(|1|lenstr={{strlen_quick|My Title (film)}}|}}-2}}&amp;lt;/nowiki&amp;gt;{{pad|2em}}&amp;amp;rarr; {{Strloc prefix|My Title (film)|strloc= {{strfind_short|My Title (film)|(|1|lenstr={{strlen_quick|My Title (film)}}|}}-2}}&lt;br /&gt;
:: In the example with &amp;quot;{{[[Template:Strfind_short|strfind_short]]}}: the number for strloc was set by finding &amp;quot;(&amp;quot; in the&amp;lt;br&amp;gt;title. If there had been no parenthesis &amp;quot;(&amp;quot; then the result would get the entire title.&lt;br /&gt;
&lt;br /&gt;
===Limitations=== &lt;br /&gt;
The text extracted is subject to the limitations of [[WP:Parser function|parser functions]] {#ifexpr:} and {padleft:}. In particular, spaces around the prefixed string are dropped, and NOT counted, before or after:&lt;br /&gt;
:* &amp;lt;nowiki&amp;gt;{{Strloc prefix| Title here |strloc=9}}&amp;lt;/nowiki&amp;gt; &amp;amp;nbsp; &amp;amp;rarr; &amp;quot;{{Strloc prefix| Title here |strloc=9}}&amp;quot;&lt;br /&gt;
:* &amp;lt;nowiki&amp;gt;{{Strloc prefix| Title here |strloc=0}}&amp;lt;/nowiki&amp;gt; &amp;amp;nbsp; &amp;amp;rarr; &amp;quot;{{Strloc prefix| Title here |strloc=0}}&amp;quot;&lt;br /&gt;
Spaces embedded within the prefix string are ''real'' spaces (NOT &amp;quot;&amp;amp;amp;#32;&amp;quot;), and any accented or special characters can be used in the string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Templates|{{PAGENAME}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>JChris.FillionR</name></author>
		
	</entry>
</feed>