亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 73.html

?? Tcl 語言的入門級圖書
?? HTML
字號:
<HTML><TITLE>Regexp and Regsub: Regular-Expression  versus Glob Patterns</TITLE><BODY BGCOLOR="#FFF0E0" VLINK="#0FBD0F" TEXT="#101000" LINK="#0F0FDD">
<A NAME="top"><H1>Regular-Expression  versus Glob Patterns</H1></A>


<P> Regular-expression pattern matching is similar to glob pattern matching
in these ways:

<UL>

<P> <P><LI> Both accept exact matches between the pattern string and the given string.

<P>  However, regular-expression matching also accepts exact matches between the
pattern string and a substring of the given string.  Substrings, of course,
contain consecutive characters.  <CITE>When more than one substring matches, a
substring that begins earlier has precedence.</CITE>  Rules for breaking other ties
are explained later.

<P> <P><LI> Both accept those inexact matches that are accounted for by special
characters in the pattern string.

<P> <P><LI> Both will match square brackets against a single character &#150; the point
of the brackets being to define a set of acceptable characters.  For example,
<TT>[a-z]</TT> will match a single lowercase letter and <TT>[:;]</TT> will match
either a colon or a semicolon.  (See 
<A HREF="NotHere.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/NotHere.html">Glob Patterns</A>.)

<P> However, regular-expression matching provides another way of specifying the
set of characters that are acceptable matches.  If the character immediately
after the <TT>[</TT> is a <TT>^</TT>, then the match will be with <CITE>any</CITE> ASCII
character which is <CITE>not</CITE> listed.  For example, <TT>[^&#38;]</TT> matches any
character except the ampersand and <TT>[^a-zA-Z]</TT> matches any character except
a letter.  (Some glob pattern matchers accept this kind of pattern too,
but this feature is not universal in the glob world.)

<P> Another small difference is that the strange acceptance of <TT>[z-a]</TT> by
Tcl's glob pattern matcher is not carried over to regular-expression pattern
matching.

<P> <P><LI> Both use backslash substitution, called backslash quoting, to permit
special characters to appear without their special meanings.  For example,
<TT>\[</TT> in both means the left square bracket itself and is not a special way
of matching a single character.  
</UL>
<P>  
<P>  The special characters for regular-expression pattern matching are
a little different than for glob pattern matching.  Here they are:

<PRE>
?*[]-^.+$|()
</PRE>

<P>  You have seen how the square brackets and hyphen are used.  These
are the only globlike symbols in the list.  Others which appear to 
be globlike have different meanings in the regular expression world.

<P><A NAME="7.3a">
<STRONG>Exercise 7.3a</STRONG> </A><DL><DD>
  What will the regular expression <TT>"$Pre1_$Pre2"</TT> match
after these preassignments?

<PRE>
set Pre1_ {\[0\-9\]}
set Pre2_ "\[0-9]"
</PRE>

Suppose the second assignment is

<PRE>
set Pre2_ "[0-9]"
</PRE>

What happens?
<P>
<A HREF="7.9.html#Sol7.3a" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.9.html#Sol7.3a">Solution</A></DL>


<P>  Tcl's regular-expression pattern matcher is invoked with the
<TT><NAME=#Cregexp>regexp</A></TT> command.  Here are two forms in which <TT>regexp</TT> can be
used.  The next section explains a form in which more arguments are used.
Switches are described later in this section.

<P><CENTER><TABLE BORDER><TR><TD><DL>

<P> <DT><STRONG><PRE>regexp <CITE>?SWITCHES? PATTERN STRING</CITE></PRE></STRONG><DD> This command returns true or
false depending whether <CITE>PATTERN</CITE> matches <CITE>STRING</CITE>.

<P> <DT><STRONG><PRE>regexp <CITE>?SWITCHES? PATTERN STRING VARIABLE_NAME</CITE></PRE></STRONG><DD> This form is like
the one above except that, when there is a match, the matched substring is
assigned to <CITE>VARIABLE_NAME</CITE>.
</DL></TD></TR></TABLE></CENTER></P>

<P> Also see the use of <TT>regexp</TT> with parentheses below in 

<A HREF="7.5.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.5.html">Use Parentheses to Build more Complicated Patterns</A> and 
<A HREF="7.6.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.6.html">Use Parentheses to Extract Subpatterns</A>.

<P>  You can try this command on some glob patterns that use square
brackets in a way acceptable for regular expressions:

<PRE>
% regexp {[a-z][A-Z]} aX Match
1
% set Match
aX
% regexp {[a-z][A-Z]} AbCdEf Match
1
% set Match
bC
</PRE>

However, this violates my convention for writing regular expressions and
so I would write it this way:

<PRE>
% set Letters_ {[a-z][A-Z]}
[a-z][A-Z]
% regexp $Letters_ aX Match
1
% set Match
aX
% regexp $Letters_ AbCdEf Match
1
% set Match
bC
</PRE>

<P>  The second example shows one of the differences between regular expressions
and globs: regular expressions will match substrings.  When, as in this
case, more than one substring could match, the one which begins first
is chosen.

<P>  If you want to force a match with a whole string, it is possible.  Two of
the special symbols help.

<P>  One of these is <TT>^.</TT>  Although <TT>^</TT> has the meaning described above
when it follows the special symbol <TT>[,</TT> the meaning is different when
<TT>^</TT> appears at the <CITE>beginning of a pattern.</CITE>  At the beginning of a
pattern, it matches an imaginary empty substring that appears just before the
beginning of the string to be matched.  Here are some examples.

<PRE>
% set SmallLetter_ [a-z]
% regexp "^$SmallLetter_" AbCdEf Match
0
% regexp "^$SmallLetter_" ab Match
1
% set Match
a
% regexp "^" ab Match
1
% set Match
</PRE>

The first <TT>regexp</TT> returns 0 because the empty string before AbCdEf
is followed by the letter A which does not match <TT>[a-z]</TT>.  The last
<TT>regexp</TT> command returns the empty string, the one found just before the
<TT>ab</TT> in the pattern.

<P> <STRONG>Remark</STRONG> <DL><DD> This interpretation of what <TT>^</TT> matches and the
fact that "^" matches "ab," are not universal truths in the world of
regular-expression pattern matching.  For example, my Perl interpreter
does not agree with the last of these examples.
</DL>

<P>  Another special symbol that helps force a pattern to match a whole
string is <TT>$.</TT>  At the end of a pattern, this matches an imaginary
empty string that appears immediately after the string to be matched.

<P>  When the symbols <TT>^</TT> and <TT>$</TT> are used as just described, they are
called <CITE><NAME=#G7.3anchor>anchor</A>s</CITE> because they have the effect of anchoring the
matching substring at the beginning or ending of the given string.

<P> <P><A NAME="7.3b">
<STRONG>Exercise 7.3b</STRONG> </A><DL><DD>
   Rewrite the following with <TT>regexp.</TT>

<PRE>
string match {Tcl} $Name
</PRE>
<P>
<A HREF="7.9.html#Sol7.3b" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.9.html#Sol7.3b">Solution</A></DL>


<P> Another special symbol is the period <TT>.</TT> which matches any single
character.  This is analogous to the use of  <TT>?</TT> in glob pattern
matching.

<P> <P><A NAME="7.3c">
<STRONG>Exercise 7.3c</STRONG> </A><DL><DD>
  Preassign a subpattern, <TT>NoDot_</TT>, that matches
any character that is not a period. <P>
<A HREF="7.9.html#Sol7.3c" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.9.html#Sol7.3c">Solution</A></DL>


<P>  To finish up this section, here are the switches for <TT>regexp:</TT>

<P><CENTER><TABLE BORDER><TR><TD><DL>
<P> 
<P> <DT><STRONG><PRE>-nocase</PRE></STRONG><DD> This causes letters in <CITE>STRING</CITE> to be converted to
lowercase before matching begins.  The change only affects a copy of
<CITE>STRING</CITE> used in matching, <CITE>STRING</CITE> itself is unchanged.  The
effect is that lowercase letters in your pattern will match letters
of either case in <CITE>STRING</CITE>.

<P> <DT><STRONG><PRE>-indices</PRE></STRONG><DD> This works with the second form or <TT>regexp</TT>.  Its
effect is to cause  a two-number list to be assigned to
<CITE>VARIABLE_NAME</CITE> &#150; the first number is the first index in <CITE>STRING</CITE> of
the matching substring and the second number is the last index in <CITE>STRING</CITE>
of the matching substring.

</DL></TD></TR></TABLE></CENTER></P>

<P> <P><A NAME="7.3d">
<STRONG>Exercise 7.3d</STRONG> </A><DL><DD>
  Fill in the question marks.

<PRE>
% regexp -indices "\[a-z]ab"  abab Match
1
% set Match
?
% regexp -indices t$ catbert Match
1
% set Match
?
</PRE>
<P>
<A HREF="7.9.html#Sol7.3d" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.9.html#Sol7.3d">Solution</A></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>Previous</STRONG>
<A HREF="7.2.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.2.html">section</A><WBR>
<STRONG>Next</STRONG>
<A HREF="7.4.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/7.4.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 + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美影视一区在线| 久久国产视频网| 一区二区不卡在线播放| 日本欧美一区二区在线观看| 国产成人在线看| 欧美理论在线播放| 国产婷婷色一区二区三区在线| 亚洲一二三四在线| heyzo一本久久综合| 欧美电影免费观看高清完整版在线| 亚洲天堂av老司机| 国产精品69久久久久水密桃| 欧美日韩电影在线| 有码一区二区三区| 91在线观看美女| 中文字幕av一区二区三区高| 蜜桃久久精品一区二区| 欧美日韩国产精品自在自线| 蜜臀久久99精品久久久久久9 | 一区二区三区在线播放| 成人性视频网站| 久久精品欧美日韩| 国产麻豆一精品一av一免费| 91精品在线免费观看| 亚洲综合激情小说| 欧美系列亚洲系列| 一区二区三区高清| 色婷婷一区二区| 亚洲欧美另类久久久精品| 波多野结衣中文字幕一区| 久久色在线视频| 国产精品一区二区久激情瑜伽| 亚洲精品一区二区三区在线观看| 免费xxxx性欧美18vr| 日韩欧美你懂的| 久久成人综合网| 久久综合九色综合97_久久久| 精品写真视频在线观看| 精品国产乱码久久久久久1区2区 | 久久众筹精品私拍模特| 狠狠久久亚洲欧美| 精品国产三级电影在线观看| 精彩视频一区二区| 久久国产成人午夜av影院| 欧美一二三四区在线| 麻豆精品在线视频| 久久人人超碰精品| 99精品欧美一区二区三区综合在线| 国产精品三级av在线播放| 99热这里都是精品| 亚洲综合丝袜美腿| 日韩一级免费观看| 国产成人免费视频| 一区二区三区小说| 精品日产卡一卡二卡麻豆| 成人精品视频.| 亚洲国产精品久久人人爱| 欧美一级一区二区| 大桥未久av一区二区三区中文| 亚洲天堂久久久久久久| 欧美一区二区三区四区在线观看| 黄一区二区三区| 亚洲丝袜美腿综合| 91精品国产日韩91久久久久久| 国产一二精品视频| 亚洲黄色在线视频| 精品国产免费人成在线观看| 99久久精品免费看国产| 图片区小说区国产精品视频| 久久综合色鬼综合色| 99re热这里只有精品视频| 天堂精品中文字幕在线| 国产欧美日韩视频在线观看| 在线一区二区视频| 国产精品一区二区果冻传媒| 亚洲欧美日韩国产成人精品影院| 在线不卡a资源高清| 成人精品一区二区三区四区| 免费一级片91| 亚洲免费av高清| 久久久久国产精品人| 欧美日韩在线观看一区二区| 国产精品1区二区.| 日本女人一区二区三区| 综合在线观看色| 久久久久久免费毛片精品| 欧美中文一区二区三区| 成人黄色在线看| 国产在线不卡视频| 日韩国产欧美视频| 亚洲综合色自拍一区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 国产suv精品一区二区883| 午夜精品福利久久久| 亚洲欧美一区二区久久| 国产日韩欧美综合在线| 欧美大度的电影原声| 欧美四级电影网| 色综合天天狠狠| 高清不卡一二三区| 国产精品自在欧美一区| 免费成人小视频| 日韩电影免费在线| 香蕉加勒比综合久久| 亚洲一区在线看| 18涩涩午夜精品.www| 国产精品电影院| 欧美激情一区二区三区在线| 精品国免费一区二区三区| 日韩色在线观看| 日韩一卡二卡三卡四卡| 欧美精品在线视频| 91精品国产色综合久久不卡蜜臀| 欧美日韩电影一区| 日韩精品在线网站| 精品国产免费一区二区三区香蕉| 日韩精品专区在线影院观看| 日韩欧美一级在线播放| 日韩欧美一区中文| 26uuu国产电影一区二区| 久久亚洲影视婷婷| 国产精品久久久久7777按摩| 国产精品高潮久久久久无| 亚洲欧洲成人自拍| 夜夜嗨av一区二区三区中文字幕 | 国产欧美精品一区二区三区四区| 久久久久久**毛片大全| 国产精品久久久久久户外露出| 成人免费在线观看入口| 亚洲欧美日韩成人高清在线一区| 亚洲精品免费播放| 日日夜夜免费精品视频| 久久草av在线| av在线不卡网| 欧美三级一区二区| 精品国产91九色蝌蚪| 国产视频一区二区三区在线观看 | 精品精品欲导航| 欧美国产禁国产网站cc| 一区二区三区在线播| 久久爱另类一区二区小说| 成人自拍视频在线观看| 91福利在线看| 精品福利一区二区三区免费视频| 日本一区二区三区免费乱视频| 亚洲免费观看高清完整版在线观看 | 在线国产电影不卡| 日韩欧美国产综合在线一区二区三区| 久久综合九色欧美综合狠狠| 亚洲天堂2014| 久久成人精品无人区| 色婷婷av一区二区三区大白胸| 正在播放亚洲一区| 国产精品成人网| 日韩一区精品字幕| 成人avav在线| 精品国产sm最大网站免费看 | 久久亚洲二区三区| 亚洲免费av高清| 国产精品18久久久久久久久久久久| 99久久精品国产毛片| 日韩精品一区二区三区在线播放| 国产精品美女视频| 免费在线观看一区二区三区| 91网站在线观看视频| 久久久青草青青国产亚洲免观| 亚洲午夜久久久久中文字幕久| 国产精品羞羞答答xxdd| 欧美美女网站色| 亚洲精品国产无天堂网2021| 国产精品亚洲成人| 亚洲精品在线网站| 日韩国产在线观看| 欧美日韩三级在线| 亚洲日本丝袜连裤袜办公室| 国产在线精品国自产拍免费| 制服丝袜在线91| 亚洲国产日韩在线一区模特| 成人高清免费观看| 国产午夜精品在线观看| 水野朝阳av一区二区三区| 色综合久久天天| 中文字幕亚洲不卡| 成人激情午夜影院| 国产性天天综合网| 国产成人亚洲综合色影视| 日韩欧美国产小视频| 图片区日韩欧美亚洲| 欧美日韩国产综合久久| 亚洲精品欧美专区| 在线免费亚洲电影| 一区二区三区国产精华| 91麻豆.com| 亚洲色图第一区| 99re6这里只有精品视频在线观看| 欧美国产欧美亚州国产日韩mv天天看完整 | 亚洲一二三级电影| 欧美视频完全免费看| 亚洲第一久久影院| 欧美电影一区二区三区|