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

📄 regexp.n

📁 tcl是工具命令语言
💻 N
字号:
'\"'\" Copyright (c) 1998 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: regexp.n,v 1.12 2002/10/10 14:46:57 dgp Exp $'\" .so man.macros.TH regexp n 8.3 Tcl "Tcl Built-In Commands".BS'\" Note:  do not modify the .SH NAME line immediately below!.SH NAMEregexp \- Match a regular expression against a string.SH SYNOPSIS\fBregexp \fR?\fIswitches\fR? \fIexp string \fR?\fImatchVar\fR? ?\fIsubMatchVar subMatchVar ...\fR?.BE.SH DESCRIPTION.PPDetermines whether the regular expression \fIexp\fR matches part orall of \fIstring\fR and returns 1 if it does, 0 if it doesn't, unless\fB-inline\fR is specified (see below).(Regular expression matching is described in the \fBre_syntax\fRreference page.).LPIf additional arguments are specified after \fIstring\fR then theyare treated as the names of variables in which to returninformation about which part(s) of \fIstring\fR matched \fIexp\fR.\fIMatchVar\fR will be set to the range of \fIstring\fR thatmatched all of \fIexp\fR.  The first \fIsubMatchVar\fR will containthe characters in \fIstring\fR that matched the leftmost parenthesizedsubexpression within \fIexp\fR, the next \fIsubMatchVar\fR willcontain the characters that matched the next parenthesizedsubexpression to the right in \fIexp\fR, and so on..PPIf the initial arguments to \fBregexp\fR start with \fB\-\fR thenthey are treated as switches.  The following switches arecurrently supported:.TP 15\fB\-about\fRInstead of attempting to match the regular expression, returns a listcontaining information about the regular expression.  The firstelement of the list is a subexpression count.  The second element is alist of property names that describe various attributes of the regularexpression. This switch is primarily intended for debugging purposes..TP 15\fB\-expanded\fREnables use of the expanded regular expression syntax wherewhitespace and comments are ignored.  This is the same as specifyingthe \fB(?x)\fR embedded option (see the \fBre_syntax\fR manual page)..TP 15\fB\-indices\fRChanges what is stored in the \fIsubMatchVar\fRs. Instead of storing the matching characters from \fIstring\fR,each variablewill contain a list of two decimal strings giving the indicesin \fIstring\fR of the first and last characters in the matchingrange of characters..TP 15\fB\-line\fREnables newline-sensitive matching.  By default, newline is acompletely ordinary character with no special meaning.  With thisflag, `[^' bracket expressions and `.' never match newline, `^'matches an empty string after any newline in addition to its normalfunction, and `$' matches an empty string before any newline inaddition to its normal function.  This flag is equivalent tospecifying both \fB\-linestop\fR and \fB\-lineanchor\fR, or the\fB(?n)\fR embedded option (see the \fBre_syntax\fR manual page)..TP 15\fB\-linestop\fRChanges the behavior of `[^' bracket expressions and `.' so that theystop at newlines.  This is the same as specifying the \fB(?p)\fRembedded option (see the \fBre_syntax\fR manual page)..TP 15\fB\-lineanchor\fRChanges the behavior of `^' and `$' (the ``anchors'') so they match thebeginning and end of a line respectively.  This is the same asspecifying the \fB(?w)\fR embedded option (see the \fBre_syntax\fRmanual page)..TP 15\fB\-nocase\fRCauses upper-case characters in \fIstring\fR to be treated aslower case during the matching process..VS 8.3.TP 15\fB\-all\fRCauses the regular expression to be matched as many times as possiblein the string, returning the total number of matches found.  If thisis specified with match variables, they will contain information forthe last match only..TP 15\fB\-inline\fRCauses the command to return, as a list, the data that would otherwisebe placed in match variables.  When using \fB-inline\fR,match variables may not be specified.  If used with \fB-all\fR, thelist will be concatenated at each iteration, such that a flat list isalways returned.  For each match iteration, the command will append theoverall match data, plus one element for each subexpression in theregular expression.  Examples are:.CS    regexp -inline -- {\\w(\\w)} " inlined " => {in n}    regexp -all -inline -- {\\w(\\w)} " inlined " => {in n li i ne e}.CE.TP 15\fB\-start\fR \fIindex\fRSpecifies a character index offset into the string to startmatching the regular expression at.  When using this switch, `^'will not match the beginning of the line, and \\A will stillmatch the start of the string at \fIindex\fR.  If \fB\-indices\fRis specified, the indices will be indexed starting from theabsolute beginning of the input string.\fIindex\fR will be constrained to the bounds of the input string..VE 8.3.TP 15\fB\-\|\-\fRMarks the end of switches.  The argument following this one willbe treated as \fIexp\fR even if it starts with a \fB\-\fR..PPIf there are more \fIsubMatchVar\fR's than parenthesizedsubexpressions within \fIexp\fR, or if a particular subexpressionin \fIexp\fR doesn't match the string (e.g. because it was in aportion of the expression that wasn't matched), then the corresponding\fIsubMatchVar\fR will be set to ``\fB\-1 \-1\fR'' if \fB\-indices\fRhas been specified or to an empty string otherwise..SH "SEE ALSO"re_syntax(n), regsub(n).SH KEYWORDSmatch, regular expression, string

⌨️ 快捷键说明

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