diff6-10.chapter23.txt

このページは最後に更新されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

last mod. 2008-08-28 (木) 09:57:42

diff6-10

27a28
> 
31d31
<    
38,39d37
<    
<    
44,64c42
<                 Compile a regular expression. The syntax for regular
<                expressions  is the same as in Gnu Emacs. The special characters
<                are  $^.*+?[]. The following constructs are recognized:
<                 
<                 - .  matches any character except newline 
<                 - *  (postfix) matches the previous expression zero, one or 
<                   several times 
<                 - +  (postfix) matches the previous expression one or  several
<                   times 
<                 - ?  (postfix) matches the previous expression once or  not at
<                   all 
<                 - [..]  character set; ranges are denoted with -, as in [a-z]; 
<                   an initial ^, as in [^0-9], complements the set 
<                 - ^ matches at beginning of line 
<                 - $  matches at end of line 
<                 - \|  (infix) alternative between two expressions 
<                 - \(..\) grouping and naming of the enclosed expression 
<                 - \1  the text matched by the first \(...\) expression  (\2 for
<                   the second expression, etc) 
<                 - \b  matches word boundaries 
<                 - \  quotes special characters. 
---
>     Compile a regular expression. The following constructs are recognized:
65a44,61
>     - .  Matches any character except newline. 
>     - *  (postfix) Matches the preceding expression zero, one or several times 
>     - +  (postfix) Matches the preceding expression one or several times 
>     - ?  (postfix) Matches the preceding expression once or not at all 
>     - [..]  Character set. Ranges are denoted with -, as in [a-z]. An initial
>       ^, as in [^0-9], complements the set. To include a ] character in a set,
>       make it the first character of the set. To include a - character in a
>       set, make it the first or the last character of the set. 
>     - ^ Matches at beginning of line (either at the beginning of the matched
>       string, or just after a newline character). 
>     - $  Matches at end of line (either at the end of the matched string, or
>       just before a newline character). 
>     - \|  (infix) Alternative between two expressions. 
>     - \(..\) Grouping and naming of the enclosed expression. 
>     - \1  The text matched by the first \(...\) expression (\2 for the second
>       expression, and so on up to \9). 
>     - \b  Matches word boundaries. 
>     - \  Quotes special characters. The special characters are $^.*+?[]. 
72,76c68,70
<                 Same as regexp, but the compiled expression will match text  in
<                a case-insensitive way: uppercase and lowercase letters will  be
<                considered equivalent.
<   
<    
---
>     Same as regexp, but the compiled expression will match text in a
>    case-insensitive way: uppercase and lowercase letters will be considered
>    equivalent.
82,85c76,77
<                 Str.quote s returns a regexp string that matches exactly  s and
<                nothing else.
<   
<    
---
>     Str.quote s returns a regexp string that matches exactly s and nothing
>    else.
91,94c83,84
<                 Str.regexp_string s returns a regular expression  that matches
<                exactly s and nothing else.
<   
<    
---
>     Str.regexp_string s returns a regular expression that matches exactly s and
>    nothing else.
100,102c90,91
<                 Str.regexp_string_case_fold is similar to
<                Str.regexp_string[23.1],   but the regexp matches in a
<                case-insensitive way.
---
>     Str.regexp_string_case_fold is similar to Str.regexp_string[23.1],  but the
>    regexp matches in a case-insensitive way.
109d97
<    
114,118c102,104
<                 string_match r s start tests whether the characters in s 
<                starting at position start match the regular expression r.  The
<                first character of a string has position 0, as usual.
<   
<    
---
>     string_match r s start tests whether a substring of s that starts at
>    position start matches the regular expression r. The first character of a
>    string has position 0, as usual.
124,130c110,113
<                 search_forward r s start searchs the string s for a substring 
<                matching the regular expression r. The search starts at position
<                 start and proceeds towards the end of the string.  Return the
<                position of the first character of the matched  substring, or
<                raise Not_found if no substring matches.
<   
<    
---
>     search_forward r s start searches the string s for a substring matching the
>    regular expression r. The search starts at position start and proceeds
>    towards the end of the string. Return the position of the first character of
>    the matched substring, or raise Not_found if no substring matches.
136,139c119,123
<                 Same as Str.search_forward[23.1], but the search proceeds
<                towards the  beginning of the string.
<   
<    
---
>     search_backward r s last searches the string s for a substring matching the
>    regular expression r. The search first considers substrings that start at
>    position last and proceeds towards the beginning of string. Return the
>    position of the first character of the matched substring; raise Not_found if
>    no substring matches.
145,149c129,131
<                 Similar to Str.string_match[23.1], but succeeds whenever the
<                argument  string is a prefix of a string that matches. This
<                includes  the case of a true complete match.
<   
<    
---
>     Similar to Str.string_match[23.1], but also returns true if the argument
>    string is a prefix of a string that matches. This includes the case of a
>    true complete match.
155,161c137,140
<                 matched_string s returns the substring of s that was matched 
<                by the latest Str.string_match[23.1], Str.search_forward[23.1]
<                or   Str.search_backward[23.1].  The user must make sure that
<                the parameter s is the same string  that was passed to the
<                matching or searching function.
<   
<    
---
>     matched_string s returns the substring of s that was matched by the latest
>    Str.string_match[23.1], Str.search_forward[23.1] or 
>    Str.search_backward[23.1]. The user must make sure that the parameter s is
>    the same string that was passed to the matching or searching function.
167,168c146,147
<                 match_beginning() returns the position of the first character 
<                of the substring that was matched by Str.string_match[23.1], 
---
>     match_beginning() returns the position of the first character of the
>    substring that was matched by Str.string_match[23.1],
171,172d149
<    
<    
177,181c154,156
<                 match_end() returns the position of the character following the
<                  last character of the substring that was matched by
<                string_match,  search_forward or search_backward.
<   
<    
---
>     match_end() returns the position of the character following the  last
>    character of the substring that was matched by string_match, search_forward
>    or search_backward.
187,199c162,171
<                 matched_group n s returns the substring of s that was matched 
<                by the nth group \(...\) of the regular expression during  the
<                latest Str.string_match[23.1], Str.search_forward[23.1] or  
<                Str.search_backward[23.1].  The user must make sure that the
<                parameter s is the same string  that was passed to the matching
<                or searching function.  matched_group n s raises Not_found if
<                the nth group  of the regular expression was not matched. This
<                can happen  with groups inside alternatives \|, options ?  or
<                repetitions *. For instance, the empty string will match 
<                \(a\)*, but matched_group 1 "" will raise Not_found  because the
<                first group itself was not matched.
<   
<    
---
>     matched_group n s returns the substring of s that was matched by the nth
>    group \(...\) of the regular expression during the latest
>    Str.string_match[23.1], Str.search_forward[23.1] or 
>    Str.search_backward[23.1]. The user must make sure that the parameter s is
>    the same string that was passed to the matching or searching function.
>    matched_group n s raises Not_found if the nth group of the regular
>    expression was not matched. This can happen with groups inside alternatives
>    \|, options ? or repetitions *. For instance, the empty string will match
>    \(a\)*, but matched_group 1 "" will raise Not_found because the first group
>    itself was not matched.
205,210c177,183
<                 group_beginning n returns the position of the first character 
<                of the substring that was matched by the nth group of  the
<                regular expression.
<                Raises Not_found if the nth group of the regular expression  was
<                not matched.
<   
---
>     group_beginning n returns the position of the first character of the
>    substring that was matched by the nth group of the regular expression.
>    Raises 
>      
>     - Not_found if the nth group of the regular expression was not matched. 
>     - Invalid_argument if there are fewer than n groups in the regular
>       expression. 
217,221c190,198
<                 group_end n returns  the position of the character following
<                the last character of  substring that was matched by the nth
<                group of the regular expression.
<                Raises Not_found if the nth group of the regular expression  was
<                not matched.
---
>     group_end n returns the position of the character following the last
>    character of substring that was matched by the nth group of the regular
>    expression.
>    Raises 
>      
>     - Not_found if the nth group of the regular expression was not matched. 
>     - Invalid_argument if there are fewer than n groups in the regular
>       expression. 
>    
228d204
<    
233,240c209,213
<                 global_replace regexp templ s returns a string identical to s, 
<                except that all substrings of s that match regexp have been 
<                replaced by templ. The replacement template templ can contain 
<                \1, \2, etc; these sequences will be replaced by the text 
<                matched by the corresponding group in the regular expression. 
<                \0 stands for the text matched by the whole regular expression.
<   
<    
---
>     global_replace regexp templ s returns a string identical to s, except that
>    all substrings of s that match regexp have been replaced by templ. The
>    replacement template templ can contain \1, \2, etc; these sequences will be
>    replaced by the text matched by the corresponding group in the regular
>    expression. \0 stands for the text matched by the whole regular expression.
246,249c219,220
<                 Same as Str.global_replace[23.1], except that only the first
<                substring  matching the regular expression is replaced.
<   
<    
---
>     Same as Str.global_replace[23.1], except that only the first substring
>    matching the regular expression is replaced.
255,261c226,229
<                 global_substitute regexp subst s returns a string identical  to
<                s, except that all substrings of s that match regexp  have been
<                replaced by the result of function subst. The  function subst is
<                called once for each matching substring,  and receives s (the
<                whole text) as argument.
<   
<    
---
>     global_substitute regexp subst s returns a string identical to s, except
>    that all substrings of s that match regexp have been replaced by the result
>    of function subst. The function subst is called once for each matching
>    substring, and receives s (the whole text) as argument.
267,270c235,236
<                 Same as Str.global_substitute[23.1], except that only the first
<                substring  matching the regular expression is replaced.
<   
<    
---
>     Same as Str.global_substitute[23.1], except that only the first substring
>    matching the regular expression is replaced.
276,280c242,245
<                 replace_matched repl s returns the replacement text repl  in
<                which \1, \2, etc. have been replaced by the text  matched by
<                the corresponding groups in the most recent matching  operation.
<                s must be the same string that was matched during  this matching
<                operation.
---
>     replace_matched repl s returns the replacement text repl in which \1, \2,
>    etc. have been replaced by the text matched by the corresponding groups in
>    the most recent matching operation. s must be the same string that was
>    matched during this matching operation.
287d251
<    
292,298c256,259
<                 split r s splits s into substrings, taking as delimiters  the
<                substrings that match r, and returns the list of substrings. 
<                For instance, split (regexp "[ \t]+") s splits s into 
<                blank-separated words. An occurrence of the delimiter at the 
<                beginning and at the end of the string is ignored.
<   
<    
---
>     split r s splits s into substrings, taking as delimiters the substrings
>    that match r, and returns the list of substrings. For instance, split
>    (regexp "[ \t]+") s splits s into blank-separated words. An occurrence of
>    the delimiter at the beginning and at the end of the string is ignored.
304,307c265,266
<                 Same as Str.split[23.1], but splits into at most n substrings, 
<                where n is the extra integer parameter.
<   
<    
---
>     Same as Str.split[23.1], but splits into at most n substrings, where n is
>    the extra integer parameter.
313,319c272,275
<                 Same as Str.split[23.1] but occurrences of the  delimiter at
<                the beginning and at the end of the string are  recognized and
<                returned as empty strings in the result.  For instance,
<                split_delim (regexp " ") " abc "  returns [""; "abc"; ""], while
<                split with the same  arguments returns ["abc"].
<   
<    
---
>     Same as Str.split[23.1] but occurrences of the delimiter at the beginning
>    and at the end of the string are recognized and returned as empty strings in
>    the result. For instance, split_delim (regexp " ") " abc " returns ["";
>    "abc"; ""], while split with the same arguments returns ["abc"].
325,331c281,283
<                 Same as Str.bounded_split[23.1], but occurrences of the 
<                delimiter at the beginning and at the end of the string are 
<                recognized and returned as empty strings in the result.  For
<                instance, split_delim (regexp " ") " abc "  returns [""; "abc";
<                ""], while split with the same  arguments returns ["abc"].
<   
<    
---
>     Same as Str.bounded_split[23.1], but occurrences of the delimiter at the
>    beginning and at the end of the string are recognized and returned as empty
>    strings in the result.
339d290
<    
344,350c295,298
<                 Same as Str.split_delim[23.1], but returns  the delimiters as
<                well as the substrings contained between  delimiters. The former
<                are tagged Delim in the result list;  the latter are tagged
<                Text. For instance,  full_split (regexp "[{}]") "{ab}" returns 
<                [Delim "{"; Text "ab"; Delim "}"].
<   
<    
---
>     Same as Str.split_delim[23.1], but returns the delimiters as well as the
>    substrings contained between delimiters. The former are tagged Delim in the
>    result list; the latter are tagged Text. For instance, full_split (regexp
>    "[{}]") "{ab}" returns [Delim "{"; Text "ab"; Delim "}"].
356,360c304,306
<                 Same as Str.bounded_split_delim[23.1], but returns  the
<                delimiters as well as the substrings contained between 
<                delimiters. The former are tagged Delim in the result list;  the
<                latter are tagged Text. For instance,  full_split (regexp
<                "[{}]") "{ab}" returns  [Delim "{"; Text "ab"; Delim "}"].
---
>     Same as Str.bounded_split_delim[23.1], but returns the delimiters as well
>    as the substrings contained between delimiters. The former are tagged Delim
>    in the result list; the latter are tagged Text.
367d312
<    
372,376c317,318
<                 string_before s n returns the substring of all characters of s 
<                that precede position n (excluding the character at  position
<                n).
<   
<    
---
>     string_before s n returns the substring of all characters of s that precede
>    position n (excluding the character at position n).
382,385c324,325
<                 string_after s n returns the substring of all characters of s 
<                that follow position n (including the character at  position n).
<   
<    
---
>     string_after s n returns the substring of all characters of s that follow
>    position n (including the character at position n).
391,394c331,332
<                 first_chars s n returns the first n characters of s.  This is
<                the same function as Str.string_before[23.1].
<   
<    
---
>     first_chars s n returns the first n characters of s. This is the same
>    function as Str.string_before[23.1].
405d342
<

新規 編集 添付