/[emacs]/emacs/lispref/searching.texi
ViewVC logotype

Diff of /emacs/lispref/searching.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.39 by rms, Sat May 4 06:33:47 2002 UTC revision 1.39.2.1 by miles, Fri Apr 4 06:20:42 2003 UTC
# Line 1  Line 1 
1  @c -*-texinfo-*-  @c -*-texinfo-*-
2  @c This is part of the GNU Emacs Lisp Reference Manual.  @c This is part of the GNU Emacs Lisp Reference Manual.
3  @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999  @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
4  @c   Free Software Foundation, Inc.  @c   Free Software Foundation, Inc.
5  @c See the file elisp.texi for copying conditions.  @c See the file elisp.texi for copying conditions.
6  @setfilename ../info/searching  @setfilename ../info/searching
7  @node Searching and Matching, Syntax Tables, Non-ASCII Characters, Top  @node Searching and Matching, Syntax Tables, Non-ASCII Characters, Top
# Line 325  multibyte character @var{c2}, the range Line 325  multibyte character @var{c2}, the range
325  is @samp{@var{c}..?\377}, the other is @samp{@var{c1}..@var{c2}}, where  is @samp{@var{c}..?\377}, the other is @samp{@var{c1}..@var{c2}}, where
326  @var{c1} is the first character of the charset to which @var{c2}  @var{c1} is the first character of the charset to which @var{c2}
327  belongs.  belongs.
328    
329  You cannot always match all non-@sc{ascii} characters with the regular  You cannot always match all non-@sc{ascii} characters with the regular
330  expression @code{"[\200-\377]"}.  This works when searching a unibyte  expression @code{"[\200-\377]"}.  This works when searching a unibyte
331  buffer or string (@pxref{Text Representations}), but not in a multibyte  buffer or string (@pxref{Text Representations}), but not in a multibyte
# Line 483  but no other string.@refill Line 483  but no other string.@refill
483  surrounding @samp{\( @dots{} \)} grouping can limit the grouping power of  surrounding @samp{\( @dots{} \)} grouping can limit the grouping power of
484  @samp{\|}.@refill  @samp{\|}.@refill
485    
486  Full backtracking capability exists to handle multiple uses of  If you need full backtracking capability to handle multiple uses of
487  @samp{\|}, if you use the POSIX regular expression functions  @samp{\|}, use the POSIX regular expression functions (@pxref{POSIX
488  (@pxref{POSIX Regexps}).  Regexps}).
489    
490  @item \@{@var{m}\@}  @item \@{@var{m}\@}
491  is a postfix operator that repeats the previous pattern exactly @var{m}  is a postfix operator that repeats the previous pattern exactly @var{m}
# Line 532  To record a matched substring for future Line 532  To record a matched substring for future
532  This last application is not a consequence of the idea of a  This last application is not a consequence of the idea of a
533  parenthetical grouping; it is a separate feature that was assigned as a  parenthetical grouping; it is a separate feature that was assigned as a
534  second meaning to the same @samp{\( @dots{} \)} construct because, in  second meaning to the same @samp{\( @dots{} \)} construct because, in
535  pratice, there was usually no conflict between the two meanings.  But  practice, there was usually no conflict between the two meanings.  But
536  occasionally there is a conflict, and that led to the introduction of  occasionally there is a conflict, and that led to the introduction of
537  shy groups.  shy groups.
538    
# Line 670  an @code{invalid-regexp} error is signal Line 670  an @code{invalid-regexp} error is signal
670    
671    Here is a complicated regexp, used by Emacs to recognize the end of a    Here is a complicated regexp, used by Emacs to recognize the end of a
672  sentence together with any whitespace that follows.  It is the value of  sentence together with any whitespace that follows.  It is the value of
673  the variable @code{sentence-end}.    the variable @code{sentence-end}.
674    
675    First, we show the regexp as a string in Lisp syntax to distinguish    First, we show the regexp as a string in Lisp syntax to distinguish
676  spaces from tab characters.  The string constant begins and ends with a  spaces from tab characters.  The string constant begins and ends with a
# Line 689  will see the following: Line 689  will see the following:
689  @example  @example
690  @group  @group
691  sentence-end  sentence-end
692       @result{} "[.?!][]\"')@}]*\\($\\| $\\|  \\|  \\)[             @result{} "[.?!][]\"')@}]*\\($\\| $\\|  \\|  \\)[
693  ]*"  ]*"
694  @end group  @end group
695  @end example  @end example
# Line 959  possibilities and found all matches, so Line 959  possibilities and found all matches, so
959  match, as required by POSIX.  This is much slower, so use these  match, as required by POSIX.  This is much slower, so use these
960  functions only when you really need the longest match.  functions only when you really need the longest match.
961    
962      The POSIX search and match functions do not properly support the
963    non-greedy repetition operators.  This is because POSIX backtracking
964    conflicts with the semantics of non-greedy repetition.
965    
966  @defun posix-search-forward regexp &optional limit noerror repeat  @defun posix-search-forward regexp &optional limit noerror repeat
967  This is like @code{re-search-forward} except that it performs the full  This is like @code{re-search-forward} except that it performs the full
968  backtracking specified by the POSIX standard for regular expression  backtracking specified by the POSIX standard for regular expression
# Line 1060  A positive number means to include that Line 1064  A positive number means to include that
1064  @section Search and Replace  @section Search and Replace
1065  @cindex replacement  @cindex replacement
1066    
1067  @defun perform-replace from-string replacements start end query-flag regexp-flag delimited-flag &optional repeat-count map  @defun perform-replace from-string replacements query-flag regexp-flag delimited-flag &optional repeat-count map start end
1068  This function is the guts of @code{query-replace} and related  This function is the guts of @code{query-replace} and related
1069  commands.  It searches for occurrences of @var{from-string} in the  commands.  It searches for occurrences of @var{from-string} in the
1070  text between positions @var{start} and @var{end} and replaces some or  text between positions @var{start} and @var{end} and replaces some or
1071  all of them.  If @var{start} is @code{nil}, point is used instead, and  all of them.  If @var{start} is @code{nil} (or omitted), point is used
1072  the buffer's end is used for @var{end}.  instead, and the buffer's end is used for @var{end}.
1073    
1074  If @var{query-flag} is @code{nil}, it replaces all  If @var{query-flag} is @code{nil}, it replaces all
1075  occurrences; otherwise, it asks the user what to do about each one.  occurrences; otherwise, it asks the user what to do about each one.
# Line 1255  just the text that matched @samp{\(ba*r\ Line 1259  just the text that matched @samp{\(ba*r\
1259  @subsection Simple Match Data Access  @subsection Simple Match Data Access
1260    
1261    This section explains how to use the match data to find out what was    This section explains how to use the match data to find out what was
1262  matched by the last search or match operation.  matched by the last search or match operation, if it succeeded.
1263    
1264    You can ask about the entire matching text, or about a particular    You can ask about the entire matching text, or about a particular
1265  parenthetical subexpression of a regular expression.  The @var{count}  parenthetical subexpression of a regular expression.  The @var{count}
# Line 1273  only information available is about the Line 1277  only information available is about the
1277    
1278    A search which fails may or may not alter the match data.  In the    A search which fails may or may not alter the match data.  In the
1279  past, a failing search did not do this, but we may change it in the  past, a failing search did not do this, but we may change it in the
1280  future.  future.  So don't try to rely on the value of the match data after
1281    a failing search.
1282    
1283  @defun match-string count &optional in-string  @defun match-string count &optional in-string
1284  This function returns, as a string, the text matched in the last search  This function returns, as a string, the text matched in the last search
# Line 1325  positions within the text: Line 1330  positions within the text:
1330  @group  @group
1331  (string-match "\\(qu\\)\\(ick\\)"  (string-match "\\(qu\\)\\(ick\\)"
1332                "The quick fox jumped quickly.")                "The quick fox jumped quickly.")
1333                ;0123456789                      ;0123456789
1334       @result{} 4       @result{} 4
1335  @end group  @end group
1336    

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.39.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26