<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
string-searching	B-Algorithm
algorithms	I-Algorithm
,	O
sometimes	O
called	O
string-matching	O
algorithms	O
,	O
are	O
an	O
important	O
class	O
of	O
string	O
algorithms	O
that	O
try	O
to	O
find	O
a	O
place	O
where	O
one	O
or	O
several	O
strings	O
(	O
also	O
called	O
patterns	O
)	O
are	O
found	O
within	O
a	O
larger	O
string	O
or	O
text	O
.	O
</s>
<s>
A	O
basic	O
example	O
of	O
string	B-Algorithm
searching	I-Algorithm
is	O
when	O
the	O
pattern	O
and	O
the	O
searched	O
text	O
are	O
arrays	B-Data_Structure
of	O
elements	O
of	O
an	O
alphabet	O
(	O
finite	O
set	O
)	O
Σ	O
.	O
Σ	O
may	O
be	O
a	O
human	O
language	O
alphabet	O
,	O
for	O
example	O
,	O
the	O
letters	O
A	O
through	O
Z	O
and	O
other	O
applications	O
may	O
use	O
a	O
binary	O
alphabet	O
( Σ	O
=	O
 { 0 , 1 } 	O
)	O
or	O
a	O
DNA	O
alphabet	O
( Σ	O
=	O
 { A , C , G , T } 	O
)	O
in	O
bioinformatics	O
.	O
</s>
<s>
The	O
most	O
basic	O
case	O
of	O
string	B-Algorithm
searching	I-Algorithm
involves	O
one	O
(	O
often	O
very	O
long	O
)	O
string	O
,	O
sometimes	O
called	O
the	O
haystack	O
,	O
and	O
one	O
(	O
often	O
very	O
short	O
)	O
string	O
,	O
sometimes	O
called	O
the	O
needle	O
.	O
</s>
<s>
Latin-based	O
alphabets	O
distinguish	O
lower-case	O
from	O
upper-case	O
,	O
but	O
for	O
many	O
purposes	O
string	B-Algorithm
search	I-Algorithm
is	O
expected	O
to	O
ignore	O
the	O
distinction	O
.	O
</s>
<s>
Another	O
more	O
complex	O
type	O
of	O
search	O
is	O
regular	B-Language
expression	I-Language
searching	O
,	O
where	O
the	O
user	O
constructs	O
a	O
pattern	O
of	O
characters	O
or	O
other	O
symbols	O
,	O
and	O
any	O
match	O
to	O
the	O
pattern	O
should	O
fulfill	O
the	O
search	O
.	O
</s>
<s>
For	O
example	O
,	O
to	O
catch	O
both	O
the	O
American	O
English	O
word	O
"	O
color	O
"	O
and	O
the	O
British	O
equivalent	O
"	O
colour	O
"	O
,	O
instead	O
of	O
searching	O
for	O
two	O
different	O
literal	O
strings	O
,	O
one	O
might	O
use	O
a	O
regular	B-Language
expression	I-Language
such	O
as	O
:	O
</s>
<s>
This	O
article	O
mainly	O
discusses	O
algorithms	O
for	O
the	O
simpler	O
kinds	O
of	O
string	B-Algorithm
searching	I-Algorithm
.	O
</s>
<s>
In	O
this	O
approach	O
,	O
backtracking	O
is	O
avoided	O
by	O
constructing	O
a	O
deterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
DFA	B-General_Concept
)	O
that	O
recognizes	O
stored	O
search	B-Algorithm
string	I-Algorithm
.	O
</s>
<s>
These	O
are	O
expensive	O
to	O
construct	O
—	O
they	O
are	O
usually	O
created	O
using	O
the	O
powerset	B-General_Concept
construction	I-General_Concept
—	O
but	O
are	O
very	O
quick	O
to	O
use	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
DFA	B-General_Concept
shown	O
to	O
the	O
right	O
recognizes	O
the	O
word	O
"	O
MOMMY	O
"	O
.	O
</s>
<s>
This	O
approach	O
is	O
frequently	O
generalized	O
in	O
practice	O
to	O
search	O
for	O
arbitrary	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
Knuth	O
–	O
Morris	O
–	O
Pratt	O
computes	O
a	O
DFA	B-General_Concept
that	O
recognizes	O
inputs	O
with	O
the	O
string	O
to	O
search	O
for	O
as	O
a	O
suffix	O
,	O
Boyer	B-Algorithm
–	I-Algorithm
Moore	I-Algorithm
starts	O
searching	O
from	O
the	O
end	O
of	O
the	O
needle	O
,	O
so	O
it	O
can	O
usually	O
jump	O
ahead	O
a	O
whole	O
needle-length	O
at	O
each	O
step	O
.	O
</s>
<s>
Baeza	O
–	O
Yates	O
keeps	O
track	O
of	O
whether	O
the	O
previous	O
j	O
characters	O
were	O
a	O
prefix	O
of	O
the	O
search	B-Algorithm
string	I-Algorithm
,	O
and	O
is	O
therefore	O
adaptable	O
to	O
fuzzy	B-Algorithm
string	I-Algorithm
searching	I-Algorithm
.	O
</s>
<s>
The	O
bitap	B-Algorithm
algorithm	I-Algorithm
is	O
an	O
application	O
of	O
Baeza–Yates	O
 '	O
approach	O
.	O
</s>
<s>
After	O
building	O
a	O
substring	B-Algorithm
index	I-Algorithm
,	O
for	O
example	O
a	O
suffix	B-Architecture
tree	I-Architecture
or	O
suffix	B-Algorithm
array	I-Algorithm
,	O
the	O
occurrences	O
of	O
a	O
pattern	O
can	O
be	O
found	O
quickly	O
.	O
</s>
<s>
As	O
an	O
example	O
,	O
a	O
suffix	B-Architecture
tree	I-Architecture
can	O
be	O
built	O
in	O
time	O
,	O
and	O
all	O
occurrences	O
of	O
a	O
pattern	O
can	O
be	O
found	O
in	O
time	O
under	O
the	O
assumption	O
that	O
the	O
alphabet	O
has	O
a	O
constant	O
size	O
and	O
all	O
inner	O
nodes	O
in	O
the	O
suffix	B-Architecture
tree	I-Architecture
know	O
what	O
leaves	O
are	O
underneath	O
them	O
.	O
</s>
<s>
The	O
latter	O
can	O
be	O
accomplished	O
by	O
running	O
a	O
DFS	B-Algorithm
algorithm	I-Algorithm
from	O
the	O
root	O
of	O
the	O
suffix	B-Architecture
tree	I-Architecture
.	O
</s>
<s>
Some	O
search	O
methods	O
,	O
for	O
instance	O
trigram	B-Algorithm
search	I-Algorithm
,	O
are	O
intended	O
to	O
find	O
a	O
"	O
closeness	O
"	O
score	O
between	O
the	O
search	B-Algorithm
string	I-Algorithm
and	O
the	O
text	O
rather	O
than	O
a	O
"	O
match/non	O
-match	O
"	O
.	O
</s>
<s>
These	O
are	O
sometimes	O
called	O
"	B-Algorithm
fuzzy	I-Algorithm
"	I-Algorithm
searches	I-Algorithm
.	O
</s>
<s>
2.Used	O
to	O
implement	O
the	O
memmem	O
and	O
strstr	O
search	O
functions	O
in	O
the	O
glibc	B-Language
and	O
musl	B-Language
C	B-Language
standard	I-Language
libraries	I-Language
.	O
</s>
<s>
3.Can	O
be	O
extended	O
to	O
handle	O
approximate	B-Algorithm
string	I-Algorithm
matching	I-Algorithm
and	O
(	O
potentially-infinite	O
)	O
sets	O
of	O
patterns	O
represented	O
as	O
regular	B-General_Concept
languages	I-General_Concept
.	O
</s>
<s>
The	O
Boyer	B-Algorithm
–	I-Algorithm
Moore	I-Algorithm
string-search	I-Algorithm
algorithm	I-Algorithm
has	O
been	O
the	O
standard	O
benchmark	O
for	O
the	O
practical	O
string-search	O
literature	O
.	O
</s>
<s>
They	O
are	O
represented	O
usually	O
by	O
a	O
regular	O
grammar	O
or	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
+Classes	O
of	O
string	B-Algorithm
searching	I-Algorithm
algorithmsMelichar	O
,	O
Borivoj	O
,	O
Jan	O
Holub	O
,	O
and	O
J	O
.	O
Polcar	O
.	O
</s>
<s>
Text	B-Algorithm
Searching	I-Algorithm
Algorithms	O
.	O
</s>
<s>
Volume	O
I	O
:	O
Forward	O
String	B-Algorithm
Matching	I-Algorithm
.	O
</s>
