<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Substring</id>
	<title>Substring - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Substring"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Substring&amp;action=history"/>
	<updated>2026-05-05T20:26:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Substring&amp;diff=1889386&amp;oldid=prev</id>
		<title>imported&gt;Graue: this has a cite in the body immediately below</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Substring&amp;diff=1889386&amp;oldid=prev"/>
		<updated>2025-05-30T07:25:54Z</updated>

		<summary type="html">&lt;p&gt;this has a cite in the body immediately below&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Contiguous part of a sequence of symbols}}&lt;br /&gt;
{{About|the definition of a substring|the computer function which performs this operation|String functions (programming)}}&lt;br /&gt;
{{Distinguish|text=[[subsequence]], a generalization of substring}}&lt;br /&gt;
[[File:Substring.png|thumb|&amp;quot;&amp;#039;&amp;#039;string&amp;#039;&amp;#039;&amp;quot; is a substring of &amp;quot;&amp;#039;&amp;#039;substring&amp;#039;&amp;#039;&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
In [[Formal language|formal language theory]] and [[computer science]], a &amp;#039;&amp;#039;&amp;#039;substring&amp;#039;&amp;#039;&amp;#039; is a contiguous sequence of [[Character (computing)|character]]s within a [[String (computer science)|string]]. For instance, &amp;quot;&amp;#039;&amp;#039;the best of&amp;#039;&amp;#039;&amp;quot; is a substring of &amp;quot;&amp;#039;&amp;#039;It was the best of times&amp;#039;&amp;#039;&amp;quot;. In contrast, &amp;quot;&amp;#039;&amp;#039;Itwastimes&amp;#039;&amp;#039;&amp;quot; is a subsequence of &amp;quot;&amp;#039;&amp;#039;It was the best of times&amp;#039;&amp;#039;&amp;quot;, but not a substring.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Prefixes&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;suffixes&amp;#039;&amp;#039;&amp;#039; are special cases of substrings. A prefix of a string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is a substring of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; that occurs at the beginning of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;; likewise, a suffix of a string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is a substring that occurs at the end of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The substrings of the string &amp;quot;&amp;#039;&amp;#039;apple&amp;#039;&amp;#039;&amp;quot; would be:&lt;br /&gt;
&amp;quot;&amp;#039;&amp;#039;a&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;ap&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;app&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;appl&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;apple&amp;#039;&amp;#039;&amp;quot;,&lt;br /&gt;
&amp;quot;&amp;#039;&amp;#039;p&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;pp&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;ppl&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;pple&amp;#039;&amp;#039;&amp;quot;,&lt;br /&gt;
&amp;quot;&amp;#039;&amp;#039;pl&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;ple&amp;#039;&amp;#039;&amp;quot;,&lt;br /&gt;
&amp;quot;&amp;#039;&amp;#039;l&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;le&amp;#039;&amp;#039;&amp;quot;&lt;br /&gt;
&amp;quot;&amp;#039;&amp;#039;e&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;quot; &lt;br /&gt;
(note the [[empty string]] at the end).&lt;br /&gt;
&lt;br /&gt;
== Substring ==&lt;br /&gt;
&lt;br /&gt;
A string &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; is a substring (or factor)&amp;lt;ref name=Lot97/&amp;gt; of a string &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; if there exists two strings &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;t = pus&amp;lt;/math&amp;gt;. In particular, the empty string is a substring of every string.&lt;br /&gt;
&lt;br /&gt;
Example: The string &amp;lt;math&amp;gt;u=&amp;lt;/math&amp;gt;&amp;lt;code&amp;gt;ana&amp;lt;/code&amp;gt; is equal to substrings (and subsequences) of &amp;lt;math&amp;gt;t=&amp;lt;/math&amp;gt;&amp;lt;code&amp;gt;banana&amp;lt;/code&amp;gt; at two different offsets:&lt;br /&gt;
&lt;br /&gt;
 banana&lt;br /&gt;
  |||||&lt;br /&gt;
  ana||&lt;br /&gt;
    |||&lt;br /&gt;
    ana&lt;br /&gt;
&lt;br /&gt;
The first occurrence is obtained with &amp;lt;math&amp;gt;p=&amp;lt;/math&amp;gt;&amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; and &amp;lt;math&amp;gt;s=&amp;lt;/math&amp;gt;&amp;lt;code&amp;gt;na&amp;lt;/code&amp;gt;, while the second occurrence is obtained with  &amp;lt;math&amp;gt;p=&amp;lt;/math&amp;gt;&amp;lt;code&amp;gt;ban&amp;lt;/code&amp;gt; and &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; being the empty string.&lt;br /&gt;
&lt;br /&gt;
A substring of a string is a [[#Prefix|prefix]] of a [[#Suffix|suffix]] of the string, and equivalently a suffix of a prefix; for example, &amp;lt;code&amp;gt;nan&amp;lt;/code&amp;gt; is a prefix of &amp;lt;code&amp;gt;nana&amp;lt;/code&amp;gt;, which is in turn a suffix of &amp;lt;code&amp;gt;banana&amp;lt;/code&amp;gt;. If &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; is a substring of &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;, it is also a [[subsequence]], which is a more general concept. The occurrences of a given pattern in a given string can be found with a [[string searching algorithm]]. Finding the longest string which is equal to a substring of two or more strings is known as the [[longest common substring problem]].&lt;br /&gt;
In the mathematical literature, substrings are also called &amp;#039;&amp;#039;&amp;#039;subwords&amp;#039;&amp;#039;&amp;#039; (in America) or &amp;#039;&amp;#039;&amp;#039;factors&amp;#039;&amp;#039;&amp;#039; (in Europe). {{citation needed|date=November 2020}}&lt;br /&gt;
&lt;br /&gt;
== Prefix ==&lt;br /&gt;
{{see also|String operations#Prefixes}}&lt;br /&gt;
A string &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is a prefix&amp;lt;ref name=Lot97/&amp;gt; of a string &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; if there exists a string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;t = ps&amp;lt;/math&amp;gt;. A &amp;#039;&amp;#039;proper prefix&amp;#039;&amp;#039; of a string is not equal to the string itself;&amp;lt;ref name=Kel95/&amp;gt; some sources&amp;lt;ref name=Gus97/&amp;gt; in addition restrict a proper prefix to be non-empty. A prefix can be seen as a special case of a substring.&lt;br /&gt;
&lt;br /&gt;
Example: The string &amp;lt;code&amp;gt;ban&amp;lt;/code&amp;gt; is equal to a prefix (and substring and subsequence) of the string &amp;lt;code&amp;gt;banana&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 banana&lt;br /&gt;
 |||&lt;br /&gt;
 ban&lt;br /&gt;
&lt;br /&gt;
The square subset symbol is sometimes used to indicate a prefix, so that &amp;lt;math&amp;gt;p \sqsubseteq t&amp;lt;/math&amp;gt; denotes that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is a prefix of &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. This defines a [[binary relation]] on strings, called the [[prefix relation]], which is a particular kind of [[prefix order]].&lt;br /&gt;
&lt;br /&gt;
== Suffix ==&lt;br /&gt;
&lt;br /&gt;
A string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is a suffix&amp;lt;ref name=Lot97/&amp;gt; of a string &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; if there exists a string &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;t = ps&amp;lt;/math&amp;gt;. A &amp;#039;&amp;#039;proper suffix&amp;#039;&amp;#039; of a string is not equal to the string itself. A more restricted interpretation is that it is also not empty.{{ref|Gus97}} A suffix can be seen as a special case of a substring.&lt;br /&gt;
&lt;br /&gt;
Example: The string &amp;lt;code&amp;gt;nana&amp;lt;/code&amp;gt; is equal to a suffix (and substring and subsequence) of the string &amp;lt;code&amp;gt;banana&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 banana&lt;br /&gt;
   ||||&lt;br /&gt;
   nana&lt;br /&gt;
&lt;br /&gt;
A [[suffix tree]] for a string is a [[trie]] [[data structure]] that represents all of its suffixes. Suffix trees have large numbers of applications in [[String (computer science)#String processing algorithms|string algorithms]]. The [[suffix array]] is a simplified version of this data structure that lists the start positions of the suffixes in alphabetically sorted order; it has many of the same applications.&lt;br /&gt;
&lt;br /&gt;
== Border ==&lt;br /&gt;
&lt;br /&gt;
A border is suffix and prefix of the same string, e.g. &amp;quot;bab&amp;quot; is a border of &amp;quot;babab&amp;quot; (and also of &amp;quot;baboon eating a kebab&amp;quot;).{{citation needed|date=January 2022}}&lt;br /&gt;
&lt;br /&gt;
== Superstring ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;superstring&amp;#039;&amp;#039;&amp;#039; of a finite set &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; of strings is a single string that contains every string in &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; as a substring. For example, &amp;lt;math&amp;gt;\text{bcclabccefab}&amp;lt;/math&amp;gt; is a superstring of &amp;lt;math&amp;gt;P = \{\text{abcc}, \text{efab}, \text{bccla}\}&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\text{efabccla}&amp;lt;/math&amp;gt; is a shorter one. Concatenating all members of &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt;, in arbitrary order, always obtains a trivial superstring of &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt;. Finding superstrings whose length is as small as possible is a more interesting problem. &lt;br /&gt;
&lt;br /&gt;
A string that contains every possible permutation of a specified character set is called a [[superpermutation]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Brace notation]]&lt;br /&gt;
* [[Substring index]]&lt;br /&gt;
* [[Suffix automaton]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist|refs=&lt;br /&gt;
&amp;lt;ref name=Gus97&amp;gt;{{cite book&lt;br /&gt;
 | last = Gusfield&lt;br /&gt;
 | first = Dan&lt;br /&gt;
 | orig-year = 1997&lt;br /&gt;
 | year = 1999&lt;br /&gt;
 | title = Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology&lt;br /&gt;
 | publisher = Cambridge University Press&lt;br /&gt;
 | location = US&lt;br /&gt;
 | isbn = 0-521-58519-8&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=Kel95&amp;gt;{{cite book&lt;br /&gt;
 | last = Kelley&lt;br /&gt;
 | first = Dean&lt;br /&gt;
 | year = 1995&lt;br /&gt;
 | title = Automata and Formal Languages: An Introduction&lt;br /&gt;
 | publisher = Prentice-Hall International&lt;br /&gt;
 | location = London&lt;br /&gt;
 | isbn = 0-13-497777-7&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=Lot97&amp;gt;{{cite book&lt;br /&gt;
 | last = Lothaire&lt;br /&gt;
 | first = M.&lt;br /&gt;
 | year = 1997&lt;br /&gt;
 | title = Combinatorics on words&lt;br /&gt;
 | publisher = Cambridge University Press&lt;br /&gt;
 | location = Cambridge&lt;br /&gt;
 | isbn = 0-521-59924-5&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:String (computer science)]]&lt;br /&gt;
[[Category:Formal languages]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Graue</name></author>
	</entry>
</feed>