⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 71.html

📁 Tcl 语言的入门级图书
💻 HTML
字号:
<HTML><TITLE>Regexp and Regsub: Theory and Practice</TITLE><BODY BGCOLOR="#FFF0E0" VLINK="#0FBD0F" TEXT="#101000" LINK="#0F0FDD">
<A NAME="top"><H1>Theory and Practice</H1></A>


<P>  Regular expressions come from a field called formal language theory.  In
this theory, a language is a set of strings and one's efforts are divided
between defining languages, on one hand, and developing algorithms to
recognize which strings belong to a defined language, on the other hand.

<DL><DD>
<P>  <CITE>The word "language" is used differently in this section
than in other sections.  Here it simply means a set of strings &#150; nothing
more.</CITE>  
</DL>

<P>  Although the presentation in the following sections is self-explanatory,
it is helpful for many readers to give a little thought to the differences
between the theory they have seen and the practice that is explained in
this chapter.  Here are some differences between theory and practice
as they apply to regular expressions.

<OL>

<P> <P><LI> The theory is concerned with recognizing whether a given string belongs
to a language that has been defined with a regular expression.  The practice
is not concerned with whether the given string belongs to the language, but
with determining whether a substring does.  If such a substring exists, it is
said to <CITE>match</CITE> the regular expression. In any case, the regular expression
is said to be a <CITE>pattern</CITE> which a substring may match.

<P> <P><LI>  When multiple substrings can be found in the given string, it is often
important to know which substring the finite automaton will find.  This
problem simply does not arise in the theoretical setting.

<P> <P><LI> The theory is presented with typographical tricks to distinguish between
symbols of the underlying language and symbols of the regular expressions that
define the language.  The practice (so far) lives in a world where we are
restricted to what we see on a typewriter keyboard.

<P> <P><LI> The theory assumes the strings of the language are made from a set of
symbols about which nothing further need be said.  In practice, it is necessary
to say something about the symbols.  Partly this is because of point 3,
partly this is because we need a way of representing characters that do not
appear on the keyboard or the screen, and partly this is because we need
a shorthand for representing important subsets of the symbols, for example, the
alphabetic letters.


</OL>

<P> <STRONG>Remark</STRONG> <DL><DD>

<P> Often, when we see theory in class and a related-but-different
practice in the real world, we decide that the theory is not very useful.
Sometimes that is true.  This is not one of those times.  Without formal
language theory, this chapter would have nothing to say.  

<P> What makes the theory seem irrelevant is that it must be presented in the
classroom as simply as possible.  Imagine what studying the theory would have
been like if you had needed to deal with the complications listed below.  Be
glad that others have dealt with them for you.

</DL>


<!-- Linkbar -->
<P><CENTER><FONT SIZE=2><NOBR>
<STRONG>From</STRONG>
<A HREF="javascript:if(confirm('http://www.mapfree.com/sbf/tcl/book/home.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.mapfree.com/sbf/tcl/book/home.html'" tppabs="http://www.mapfree.com/sbf/tcl/book/home.html">Tcl/Tk For Programmers</A><WBR>
<STRONG>Next</STRONG>
<A HREF="7.2.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.2.html">section</A><WBR>
<STRONG>All</STRONG>
<A HREF="7.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.html">sections</A><WBR>
<STRONG>Author</STRONG>
<A HREF="javascript:if(confirm('http://www.mapfree.com/mp/jaz/home.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.mapfree.com/mp/jaz/home.html'" tppabs="http://www.mapfree.com/mp/jaz/home.html">J. A. Zimmer</A><WBR>
<STRONG>Copyright</STRONG>
<A HREF="copyright.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/copyright.html">Notice</A><WBR>
<P>
<I>Jun 17, 1998</I>
 </NOBR></FONT></CENTER></BODY></HTML>


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -