From dfd4b66c48106edfcbdd1b32e733640e2587acbb Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 3 Dec 2009 12:21:55 +0000 Subject: documentation: Fix bugs introduced in the SGML to XML transition In the transition from SGML to XML (several releases ago), bugs were introduced in the documentation, for instance "\n" replaced by newlines. Correct those bugs. Also correct double backslashes. They seem to have been introduced very early in the development of OTP. According to Lars they "solved" a bug in the generation of HTML &c. Now that standard tools are used instead of docbuilder, the bug has become visible. --- lib/stdlib/doc/src/filename.xml | 10 +- lib/stdlib/doc/src/io_protocol.xml | 2 +- lib/stdlib/doc/src/re.xml | 424 ++++++++++++++++++------------------- lib/stdlib/doc/src/regexp.xml | 44 ++-- lib/stdlib/doc/src/shell.xml | 8 +- lib/stdlib/doc/src/string.xml | 4 +- lib/stdlib/doc/src/win32reg.xml | 6 +- 7 files changed, 250 insertions(+), 248 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/filename.xml b/lib/stdlib/doc/src/filename.xml index 3a6c5e0b60..0cf82fa48b 100644 --- a/lib/stdlib/doc/src/filename.xml +++ b/lib/stdlib/doc/src/filename.xml @@ -37,7 +37,7 @@ is meant all strings that can be used to denote a file. They can be short relative names like foo.erl, very long absolute name which include a drive designator and directory names like - D:\\usr/local\\bin\\erl/lib\\tools\\foo.erl, or any variations + D:\usr/local\bin\erl/lib\tools\foo.erl, or any variations in between.

In Windows, all functions return file names with forward slashes only, even if the arguments contain back slashes. Use @@ -173,7 +173,7 @@ name() = string() | atom() | DeepList 14> filename:dirname("kalle.erl"). "." -5> filename:dirname("\\\\usr\\\\src/kalle.erl"). % Windows +5> filename:dirname("\\usr\\src/kalle.erl"). % Windows "/usr/src" @@ -228,7 +228,7 @@ name() = string() | atom() | DeepList 18> filename:join(["a/b///c/"]). "a/b/c" -6> filename:join(["B:a\\\\b///c/"]). % Windows +6> filename:join(["B:a\\b///c/"]). % Windows "b:a/b/c" @@ -259,7 +259,7 @@ name() = string() | atom() | DeepList "/usr/local/bin" 7> filename:nativename("/usr/local/bin/"). % Windows -"\\\\usr\\\\local\\\\bin" +"\\usr\\local\\bin" @@ -329,7 +329,7 @@ name() = string() | atom() | DeepList ["/","usr","local","bin"] 25> filename:split("foo/bar"). ["foo","bar"] -26> filename:split("a:\\\\msdev\\\\include"). +26> filename:split("a:\\msdev\\include"). ["a:/","msdev","include"] diff --git a/lib/stdlib/doc/src/io_protocol.xml b/lib/stdlib/doc/src/io_protocol.xml index 1b75114031..201787f7b5 100644 --- a/lib/stdlib/doc/src/io_protocol.xml +++ b/lib/stdlib/doc/src/io_protocol.xml @@ -546,7 +546,7 @@ request({get_chars, Encoding, _Prompt, N}, State) -> get_until(Encoding, ?MODULE, until_enough, [N], State); request({get_line, Encoding, _Prompt}, State) -> %% To simplify the code, get_line is implemented using get_until - get_until(Encoding, ?MODULE, until_newline, [$\\n], State); + get_until(Encoding, ?MODULE, until_newline, [$\n], State);

Here we have cheated a little by more or less only implementing diff --git a/lib/stdlib/doc/src/re.xml b/lib/stdlib/doc/src/re.xml index 41dce7f2a7..e9a32a59d4 100644 --- a/lib/stdlib/doc/src/re.xml +++ b/lib/stdlib/doc/src/re.xml @@ -56,10 +56,10 @@

The Erlang literal syntax for strings give special - meaning to the "\\" (backslash) character. To literally write + meaning to the "\" (backslash) character. To literally write a regular expression or a replacement string containing a backslash in your code or in the shell, two backslashes have to be written: - "\\\\".

+ "\\".

@@ -163,9 +163,9 @@ This option makes it possible to include comments inside complicated patterns. N bsr_anycrlf - Specifies specifically that \\R is to match only the cr, lf or crlf sequences, not the Unicode specific newline characters. + Specifies specifically that \R is to match only the cr, lf or crlf sequences, not the Unicode specific newline characters. bsr_unicode - Specifies specifically that \\R is to match all the Unicode newline characters (including crlf etc, the default). + Specifies specifically that \R is to match all the Unicode newline characters (including crlf etc, the default). @@ -384,9 +384,9 @@ This option makes it possible to include comments inside complicated patterns. N bsr_anycrlf - Specifies specifically that \\R is to match only the cr, lf or crlf sequences, not the Unicode specific newline characters.(overrides compilation option) + Specifies specifically that \R is to match only the cr, lf or crlf sequences, not the Unicode specific newline characters.(overrides compilation option) bsr_unicode - Specifies specifically that \\R is to match all the Unicode newline characters (including crlf etc, the default).(overrides compilation option) + Specifies specifically that \R is to match all the Unicode newline characters (including crlf etc, the default).(overrides compilation option) {capture, ValueSpec}/{capture, ValueSpec, Type} @@ -471,9 +471,9 @@ This option makes it possible to include comments inside complicated patterns. N index Return captured substrings as pairs of byte indexes into the subject string and length of the matching string in the subject (as if the subject string was flattened with iolist_to_binary/1 or unicode:characters_to_binary/2 prior to matching). Note that the unicode option results in byte-oriented indexes in a (possibly imagined) UTF-8 encoded binary. A byte index tuple {0,2} might therefore represent one or two characters when unicode is in effect. This might seem contra-intuitive, but has been deemed the most effective and useful way to way to do it. To return lists instead might result in simpler code if that is desired. This return type is the default. list - Return matching substrings as lists of characters (Erlang string()'s). It the unicode option is used in combination with the \\C sequence in the regular expression, a captured subpattern can contain bytes that has is not valid UTF-8 (\\C matches bytes regardless of character encoding). In that case the list capturing may result in the same types of tuples that unicode:characters_to_list/2 can return, namely three-tuples with the tag incomplete or error, the successfully converted characters and the invalid UTF-8 tail of the conversion as a binary. The best strategy is to avoid using the\\C sequence when capturing lists. + Return matching substrings as lists of characters (Erlang string()'s). It the unicode option is used in combination with the \C sequence in the regular expression, a captured subpattern can contain bytes that has is not valid UTF-8 (\C matches bytes regardless of character encoding). In that case the list capturing may result in the same types of tuples that unicode:characters_to_list/2 can return, namely three-tuples with the tag incomplete or error, the successfully converted characters and the invalid UTF-8 tail of the conversion as a binary. The best strategy is to avoid using the \C sequence when capturing lists. binary - Return matching substrings as binaries. If the unicode option is used, these binaries is in UTF-8. If the \\C sequence is used together with unicode the binaries may be invalid UTF-8. + Return matching substrings as binaries. If the unicode option is used, these binaries is in UTF-8. If the \C sequence is used together with unicode the binaries may be invalid UTF-8. @@ -544,20 +544,20 @@ This option makes it possible to include comments inside complicated patterns. N

The replacement string can contain the special character &, which inserts the whole matching expression in the - result, and the special sequence \\N (where N is an + result, and the special sequence \N (where N is an integer > 0), resulting in the subexpression number N will be inserted in the result. If no subexpression with that number is generated by the regular expression, nothing is inserted.

-

To insert an & or \\ in the result, precede it - with a \\. Note that Erlang already gives a special - meaning to \\ in literal strings, why a single \\ - has to be written as "\\\\" and therefore a double \\ - as "\\\\\\\\". Example:

+

To insert an & or \ in the result, precede it + with a \. Note that Erlang already gives a special + meaning to \ in literal strings, why a single \ + has to be written as "\\" and therefore a double \ + as "\\\\". Example:

re:replace("abcd","c","[&]",[{return,list}]).

gives

"ab[c]d"

while

- re:replace("abcd","c","[\\\&]",[{return,list}]). + re:replace("abcd","c","[\\&]",[{return,list}]).

gives

"ab[&]d"

As with re:run/3, compilation errors raise the badarg @@ -852,19 +852,19 @@ example, the pattern:

(*CR)a.b

-

changes the convention to CR. That pattern matches "a\\nb" because LF is no +

changes the convention to CR. That pattern matches "a\nb" because LF is no longer a newline. Note that these special settings, which are not Perl-compatible, are recognized only at the very start of a pattern, and that they must be in upper case. If more than one of them is present, the last one is used.

-

The newline convention does not affect what the \\R escape sequence matches. By +

The newline convention does not affect what the \R escape sequence matches. By default, this is any Unicode newline sequence, for Perl compatibility. However, -this can be changed; see the description of \\R in the section entitled +this can be changed; see the description of \R in the section entitled "Newline sequences" -below. A change of \\R setting can be combined with a change of newline +below. A change of \R setting can be combined with a change of newline convention.

@@ -897,7 +897,7 @@ recognized within square brackets. Outside square brackets, the metacharacters are as follows:

- \\ general escape character with several uses + \ general escape character with several uses ^ assert start of string (or line, in multiline mode) $ assert end of string (or line, in multiline mode) . match any character except newline (by default) @@ -918,7 +918,7 @@ are as follows:

a character class the only metacharacters are:

- \\ general escape character + \ general escape character ^ negate the class, but only if the first character - indicates character range [ POSIX character class (only if followed by POSIX @@ -939,11 +939,11 @@ non-alphanumeric character, it takes away any special meaning that character may have. This use of backslash as an escape character applies both inside and outside character classes.

-

For example, if you want to match a * character, you write \\* in the pattern. +

For example, if you want to match a * character, you write \* in the pattern. This escaping action applies whether or not the following character would otherwise be interpreted as a metacharacter, so it is always safe to precede a non-alphanumeric with backslash to specify that it stands for itself. In -particular, if you want to match a backslash, you write \\\\.

+particular, if you want to match a backslash, you write \\.

If a pattern is compiled with the extended option, whitespace in the pattern (other than in a character class) and characters between a # outside @@ -951,18 +951,18 @@ a character class and the next newline are ignored. An escaping backslash can be used to include a whitespace or # character as part of the pattern.

If you want to remove the special meaning from a sequence of characters, you -can do so by putting them between \\Q and \\E. This is different from Perl in -that $ and @ are handled as literals in \\Q...\\E sequences in PCRE, whereas in +can do so by putting them between \Q and \E. This is different from Perl in +that $ and @ are handled as literals in \Q...\E sequences in PCRE, whereas in Perl, $ and @ cause variable interpolation. Note the following examples:

Pattern PCRE matches Perl matches - \\Qabc$xyz\\E abc$xyz abc followed by the contents of $xyz - \\Qabc\\$xyz\\E abc\\$xyz abc\\$xyz - \\Qabc\\E\\$\\Qxyz\\E abc$xyz abc$xyz + \Qabc$xyz\E abc$xyz abc followed by the contents of $xyz + \Qabc\$xyz\E abc\$xyz abc\$xyz + \Qabc\E\$\Qxyz\E abc$xyz abc$xyz -

The \\Q...\\E sequence is recognized both inside and outside character classes.

+

The \Q...\E sequence is recognized both inside and outside character classes.

Non-printing characters

@@ -975,41 +975,41 @@ use one of the following escape sequences than the binary character it represents:

- \\a alarm, that is, the BEL character (hex 07) - \\cx "control-x", where x is any character - \\e escape (hex 1B) - \\f formfeed (hex 0C) - \\n linefeed (hex 0A) - \\r carriage return (hex 0D) - \\t tab (hex 09) - \\ddd character with octal code ddd, or backreference - \\xhh character with hex code hh - \\x{hhh..} character with hex code hhh.. + \a alarm, that is, the BEL character (hex 07) + \cx "control-x", where x is any character + \e escape (hex 1B) + \f formfeed (hex 0C) + \n linefeed (hex 0A) + \r carriage return (hex 0D) + \t tab (hex 09) + \ddd character with octal code ddd, or backreference + \xhh character with hex code hh + \x{hhh..} character with hex code hhh.. -

The precise effect of \\cx is as follows: if x is a lower case letter, it +

The precise effect of \cx is as follows: if x is a lower case letter, it is converted to upper case. Then bit 6 of the character (hex 40) is inverted. -Thus \\cz becomes hex 1A, but \\c{ becomes hex 3B, while \\c; becomes hex +Thus \cz becomes hex 1A, but \c{ becomes hex 3B, while \c; becomes hex 7B.

-

After \\x, from zero to two hexadecimal digits are read (letters can be in -upper or lower case). Any number of hexadecimal digits may appear between \\x{ +

After \x, from zero to two hexadecimal digits are read (letters can be in +upper or lower case). Any number of hexadecimal digits may appear between \x{ and }, but the value of the character code must be less than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8 mode. That is, the maximum value in hexadecimal is 7FFFFFFF. Note that this is bigger than the largest Unicode code point, which is 10FFFF.

-

If characters other than hexadecimal digits appear between \\x{ and }, or if +

If characters other than hexadecimal digits appear between \x{ and }, or if there is no terminating }, this form of escape is not recognized. Instead, the -initial \\x will be interpreted as a basic hexadecimal escape, with no +initial \x will be interpreted as a basic hexadecimal escape, with no following digits, giving a character whose value is zero.

Characters whose value is less than 256 can be defined by either of the two -syntaxes for \\x. There is no difference in the way they are handled. For -example, \\xdc is exactly the same as \\x{dc}.

+syntaxes for \x. There is no difference in the way they are handled. For +example, \xdc is exactly the same as \x{dc}.

-

After \\0 up to two further octal digits are read. If there are fewer than two -digits, just those that are present are used. Thus the sequence \\0\\x\\07 +

After \0 up to two further octal digits are read. If there are fewer than two +digits, just those that are present are used. Thus the sequence \0\x\07 specifies two binary zeros followed by a BEL character (code value 7). Make sure you supply two digits after the initial zero if the pattern character that follows is itself an octal digit.

@@ -1027,32 +1027,32 @@ have not been that many capturing subpatterns, PCRE re-reads up to three octal digits following the backslash, and uses them to generate a data character. Any subsequent digits stand for themselves. The value of a -character specified in octal must be less than \\400. +character specified in octal must be less than \400. In non-UTF-8 mode, the value of a -character specified in octal must be less than \\400. In UTF-8 mode, values up -to \\777 are permitted. +character specified in octal must be less than \400. In UTF-8 mode, values up +to \777 are permitted. For example:

- \\040 is another way of writing a space + \040 is another way of writing a space - \\40 is the same, provided there are fewer than 40 + \40 is the same, provided there are fewer than 40 previous capturing subpatterns - \\7 is always a back reference + \7 is always a back reference - \\11 might be a back reference, or another way of + \11 might be a back reference, or another way of writing a tab - \\011 is always a tab - \\0113 is a tab followed by the character "3" + \011 is always a tab + \0113 is a tab followed by the character "3" - \\113 might be a back reference, otherwise the + \113 might be a back reference, otherwise the character with octal code 113 - \\377 might be a back reference, otherwise + \377 might be a back reference, otherwise the byte consisting entirely of 1 bits - \\81 is either a back reference, or a binary zero + \81 is either a back reference, or a binary zero followed by the two characters "8" and "1" @@ -1062,16 +1062,16 @@ read.

All the sequences that define a single character value can be used both inside and outside character classes. In addition, inside a -character class, the sequence \\b is interpreted as the backspace -character (hex 08), and the sequences \\R and \\X are interpreted as +character class, the sequence \b is interpreted as the backspace +character (hex 08), and the sequences \R and \X are interpreted as the characters "R" and "X", respectively. Outside a character class, these sequences have different meanings (see below).

Absolute and relative back references

-

The sequence \\g followed by an unsigned or a negative number, +

The sequence \g followed by an unsigned or a negative number, optionally enclosed in braces, is an absolute or relative back -reference. A named back reference can be coded as \\g{name}. Back +reference. A named back reference can be coded as \g{name}. Back references are discussed later, following the discussion of parenthesized subpatterns.

@@ -1081,16 +1081,16 @@ parenthesized subpatterns.

following are always recognized:

- \\d any decimal digit - \\D any character that is not a decimal digit - \\h any horizontal whitespace character - \\H any character that is not a horizontal whitespace character - \\s any whitespace character - \\S any character that is not a whitespace character - \\v any vertical whitespace character - \\V any character that is not a vertical whitespace character - \\w any "word" character - \\W any "non-word" character + \d any decimal digit + \D any character that is not a decimal digit + \h any horizontal whitespace character + \H any character that is not a horizontal whitespace character + \s any whitespace character + \S any character that is not a whitespace character + \v any vertical whitespace character + \V any character that is not a vertical whitespace character + \w any "word" character + \W any "non-word" character

Each pair of escape sequences partitions the complete set of characters into @@ -1101,19 +1101,19 @@ classes. They each match one character of the appropriate type. If the current matching point is at the end of the subject string, all of them fail, since there is no character to match.

-

For compatibility with Perl, \\s does not match the VT character (code 11). -This makes it different from the POSIX "space" class. The \\s characters +

For compatibility with Perl, \s does not match the VT character (code 11). +This makes it different from the POSIX "space" class. The \s characters are HT (9), LF (10), FF (12), CR (13), and space (32). If "use locale;" is -included in a Perl script, \\s may match the VT character. In PCRE, it never +included in a Perl script, \s may match the VT character. In PCRE, it never does.

-

In UTF-8 mode, characters with values greater than 128 never match \\d, \\s, or -\\w, and always match \\D, \\S, and \\W. This is true even when Unicode +

In UTF-8 mode, characters with values greater than 128 never match \d, \s, or +\w, and always match \D, \S, and \W. This is true even when Unicode character property support is available. These sequences retain their original meanings from before UTF-8 support was available, mainly for efficiency reasons.

-

The sequences \\h, \\H, \\v, and \\V are Perl 5.10 features. In contrast to the +

The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to the other sequences, these do match certain high-valued codepoints in UTF-8 mode. The horizontal space characters are:

@@ -1157,11 +1157,11 @@ low-valued character tables, which are always ISO-8859-1.

Newline sequences

-

Outside a character class, by default, the escape sequence \\R matches any -Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \\R is +

Outside a character class, by default, the escape sequence \R matches any +Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \R is equivalent to the following:

-

(?>\\r\\n|\\n|\\x0b|\\f|\\r|\\x85)

+

(?>\r\n|\n|\x0b|\f|\r|\x85)

This is an example of an "atomic group", details of which are given below.

@@ -1177,7 +1177,7 @@ Unicode character property support is not needed for these characters to be recognized.

-

It is possible to restrict \\R to match only CR, LF, or CRLF (instead of the +

It is possible to restrict \R to match only CR, LF, or CRLF (instead of the complete set of Unicode line endings) by setting the option bsr_anycrlf either at compile time or when the pattern is matched. (BSR is an abbreviation for "backslash R".) This can be made the default when PCRE is built; if this is @@ -1197,7 +1197,7 @@ newline convention, for example, a pattern can start with:

(*ANY)(*BSR_ANYCRLF)

-

Inside a character class, \\R matches the letter "R".

+

Inside a character class, \R matches the letter "R".

Unicode character properties

@@ -1208,22 +1208,22 @@ When not in UTF-8 mode, these sequences are of course limited to testing characters whose codepoints are less than 256, but they do work in this mode. The extra escape sequences are:

-

\\p{xx} a character with the xx property - \\P{xx} a character without the xx property - \\X an extended Unicode sequence

+

\p{xx} a character with the xx property + \P{xx} a character without the xx property + \X an extended Unicode sequence

The property names represented by xx above are limited to the Unicode script names, the general category properties, and "Any", which matches any character (including newline). Other properties such as "InMusicalSymbols" are -not currently supported by PCRE. Note that \\P{Any} does not match any +not currently supported by PCRE. Note that \P{Any} does not match any characters, so always causes a match failure.

Sets of Unicode characters are defined as belonging to certain scripts. A character from one of these sets can be matched using a script name. For example:

-

\\p{Greek} - \\P{Han}

+

\p{Greek} + \P{Han}

Those that are not part of an identified script are lumped together as "Common". The current list of scripts is:

@@ -1300,15 +1300,15 @@ example:

Each character has exactly one general category property, specified by a two-letter abbreviation. For compatibility with Perl, negation can be specified by including a circumflex between the opening brace and the property name. For -example, \\p{^Lu} is the same as \\P{Lu}.

+example, \p{^Lu} is the same as \P{Lu}.

-

If only one letter is specified with \\p or \\P, it includes all the general +

If only one letter is specified with \p or \P, it includes all the general category properties that start with that letter. In this case, in the absence of negation, the curly brackets in the escape sequence are optional; these two examples have the same effect:

-\\p{L} - \\pL +\p{L} + \pL

The following general category property codes are supported:

@@ -1382,7 +1382,7 @@ cannot be tested by PCRE, unless UTF-8 validity checking has been turned off pcreapi page).

-

The long synonyms for these properties that Perl supports (such as \\p{Letter}) +

The long synonyms for these properties that Perl supports (such as \p{Letter}) are not supported by PCRE, nor is it permitted to prefix any of these properties with "Is".

@@ -1391,12 +1391,12 @@ Instead, this property is assumed for any code point that is not in the Unicode table.

Specifying caseless matching does not affect these escape sequences. For -example, \\p{Lu} always matches only upper case letters.

+example, \p{Lu} always matches only upper case letters.

-

The \\X escape matches any number of Unicode characters that form an extended -Unicode sequence. \\X is equivalent to

+

The \X escape matches any number of Unicode characters that form an extended +Unicode sequence. \X is equivalent to

-

(?>\\PM\\pM*)

+

(?>\PM\pM*)

That is, it matches a character without the "mark" property, followed by zero or more characters with the "mark" property, and treats the sequence as an @@ -1404,20 +1404,20 @@ atomic group (see below). Characters with the "mark" property are typically accents that affect the preceding character. None of them have codepoints less than 256, so in -non-UTF-8 mode \\X matches any one character.

+non-UTF-8 mode \X matches any one character.

Matching characters by Unicode property is not fast, because PCRE has to search a structure that contains data for over fifteen thousand characters. That is -why the traditional escape sequences such as \\d and \\w do not use Unicode +why the traditional escape sequences such as \d and \w do not use Unicode properties in PCRE.

Resetting the match start

-

The escape sequence \\K, which is a Perl 5.10 feature, causes any previously +

The escape sequence \K, which is a Perl 5.10 feature, causes any previously matched characters not to be included in the final matched sequence. For example, the pattern:

-

foo\\Kbar

+

foo\Kbar

matches "foobar", but reports that it has matched "bar". This feature is similar to a lookbehind assertion @@ -1426,12 +1426,12 @@ similar to a lookbehind assertion (described below). However, in this case, the part of the subject before the real match does not -have to be of fixed length, as lookbehind assertions do. The use of \\K does +have to be of fixed length, as lookbehind assertions do. The use of \K does not interfere with the setting of captured substrings. For example, when the pattern

-

(foo)\\Kbar

+

(foo)\Kbar

matches "foobar", the first substring is still set to "foo".

@@ -1444,50 +1444,50 @@ string. The use of subpatterns for more complicated assertions is described below. The backslashed assertions are:

- \\b matches at a word boundary - \\B matches when not at a word boundary - \\A matches at the start of the subject - \\Z matches at the end of the subject + \b matches at a word boundary + \B matches when not at a word boundary + \A matches at the start of the subject + \Z matches at the end of the subject also matches before a newline at the end of the subject - \\z matches only at the end of the subject - \\G matches at the first matching position in the + \z matches only at the end of the subject + \G matches at the first matching position in the subject -

These assertions may not appear in character classes (but note that \\b has a +

These assertions may not appear in character classes (but note that \b has a different meaning, namely the backspace character, inside a character class).

A word boundary is a position in the subject string where the current character -and the previous character do not both match \\w or \\W (i.e. one matches -\\w and the other matches \\W), or the start or end of the string if the -first or last character matches \\w, respectively.

+and the previous character do not both match \w or \W (i.e. one matches +\w and the other matches \W), or the start or end of the string if the +first or last character matches \w, respectively.

-

The \\A, \\Z, and \\z assertions differ from the traditional circumflex and +

The \A, \Z, and \z assertions differ from the traditional circumflex and dollar (described in the next section) in that they only ever match at the very start and end of the subject string, whatever options are set. Thus, they are independent of multiline mode. These three assertions are not affected by the notbol or noteol options, which affect only the behaviour of the circumflex and dollar metacharacters. However, if the startoffset argument of re:run/3 is non-zero, indicating that matching is to start -at a point other than the beginning of the subject, \\A can never match. The -difference between \\Z and \\z is that \\Z matches before a newline at the end -of the string as well as at the very end, whereas \\z matches only at the end.

+at a point other than the beginning of the subject, \A can never match. The +difference between \Z and \z is that \Z matches before a newline at the end +of the string as well as at the very end, whereas \z matches only at the end.

-

The \\G assertion is true only when the current matching position is at the +

The \G assertion is true only when the current matching position is at the start point of the match, as specified by the startoffset argument of -re:run/3. It differs from \\A when the value of startoffset is +re:run/3. It differs from \A when the value of startoffset is non-zero. By calling re:run/3 multiple times with appropriate arguments, you can mimic Perl's /g option, and it is in this kind of -implementation where \\G can be useful.

+implementation where \G can be useful.

-

Note, however, that PCRE's interpretation of \\G, as the start of the current +

Note, however, that PCRE's interpretation of \G, as the start of the current match, is subtly different from Perl's, which defines it as the end of the previous match. In Perl, these can be different when the previously matched string was empty. Because PCRE does just one match at a time, it cannot reproduce this behaviour.

-

If all the alternatives of a pattern begin with \\G, the expression is anchored +

If all the alternatives of a pattern begin with \G, the expression is anchored to the starting match position, and the "anchored" flag is set in the compiled regular expression.

@@ -1519,7 +1519,7 @@ character class.

The meaning of dollar can be changed so that it matches only at the very end of the string, by setting the dollar_endonly option at -compile time. This does not affect the \\Z assertion.

+compile time. This does not affect the \Z assertion.

The meanings of the circumflex and dollar characters are changed if the multiline option is set. When this is the case, a circumflex matches @@ -1530,16 +1530,16 @@ matches before any newlines in the string, as well as at the very end, when sequence CRLF, isolated CR and LF characters do not indicate newlines.

For example, the pattern /^abc$/ matches the subject string -"def\\nabc" (where \\n represents a newline) in multiline mode, but +"def\nabc" (where \n represents a newline) in multiline mode, but not otherwise. Consequently, patterns that are anchored in single line mode because all branches start with ^ are not anchored in multiline mode, and a match for circumflex is possible when the startoffset argument of re:run/3 is non-zero. The dollar_endonly option is ignored if multiline is set.

-

Note that the sequences \\A, \\Z, and \\z can be used to match the start and +

Note that the sequences \A, \Z, and \z can be used to match the start and end of the subject in both modes, and if all branches of a pattern start with -\\A it is always anchored, whether or not multiline is set.

+\A it is always anchored, whether or not multiline is set.

@@ -1574,14 +1574,14 @@ involve newlines. Dot has no special meaning in a character class.

Matching a single byte -

Outside a character class, the escape sequence \\C matches any one byte, both +

Outside a character class, the escape sequence \C matches any one byte, both in and out of UTF-8 mode. Unlike a dot, it always matches any line-ending characters. The feature is provided in Perl in order to match individual bytes in UTF-8 mode. Because it breaks up UTF-8 characters into individual bytes, what remains in the string may be a malformed UTF-8 string. For this reason, -the \\C escape sequence is best avoided.

+the \C escape sequence is best avoided.

-

PCRE does not allow \\C to appear in lookbehind assertions (described below), +

PCRE does not allow \C to appear in lookbehind assertions (described below), because in UTF-8 mode this would make it impossible to calculate the length of the lookbehind.

@@ -1615,7 +1615,7 @@ string, and therefore it fails if the current pointer is at the end of the string.

In UTF-8 mode, characters with values greater than 255 can be included in a -class as a literal string of bytes, or by using the \\x{ escaping mechanism.

+class as a literal string of bytes, or by using the \x{ escaping mechanism.

When caseless matching is set, any letters in a class represent both their upper case and lower case versions, so for example, a caseless [aeiou] matches @@ -1648,32 +1648,32 @@ character of a range. A pattern such as [W-]46] is interpreted as a class of two characters ("W" and "-") followed by a literal string "46]", so it would match "W46]" or "-46]". However, if the "]" is escaped with a backslash it is interpreted as the end of range, so -[W-\\]46] is interpreted as a class containing a range followed by two +[W-\]46] is interpreted as a class containing a range followed by two other characters. The octal or hexadecimal representation of "]" can also be used to end a range.

Ranges operate in the collating sequence of character values. They can also be -used for characters specified numerically, for example [\\000-\\037]. +used for characters specified numerically, for example [\000-\037]. In UTF-8 mode, ranges can include characters whose values are greater than 255, for -example [\\x{100}-\\x{2ff}]. +example [\x{100}-\x{2ff}].

If a range that includes letters is used when caseless matching is set, it matches the letters in either case. For example, [W-c] is equivalent to -[][\\\\^_`wxyzabc], matched caselessly +[][\\^_`wxyzabc], matched caselessly , and in non-UTF-8 mode, if character -tables for a French locale are in use, [\\xc8-\\xcb] matches accented E +tables for a French locale are in use, [\xc8-\xcb] matches accented E characters in both cases. In UTF-8 mode, PCRE supports the concept of case for characters with values greater than 128 only when it is compiled with Unicode property support.

-

The character types \\d, \\D, \\p, \\P, \\s, \\S, \\w, and \\W may +

The character types \d, \D, \p, \P, \s, \S, \w, and \W may also appear in a character class, and add the characters that they -match to the class. For example, [\\dABCDEF] matches any hexadecimal +match to the class. For example, [\dABCDEF] matches any hexadecimal digit. A circumflex can conveniently be used with the upper case character types to specify a more restricted set of characters than -the matching lower case type. For example, the class [^\\W_] matches +the matching lower case type. For example, the class [^\W_] matches any letter or digit, but not underscore.

The only metacharacters that are recognized in character classes @@ -1702,20 +1702,20 @@ are

ascii character codes 0 - 127 blank space or tab only cntrl control characters - digit decimal digits (same as \\d) + digit decimal digits (same as \d) graph printing characters, excluding space lower lower case letters print printing characters, including space punct printing characters, excluding letters and digits - space whitespace (not quite the same as \\s) + space whitespace (not quite the same as \s) upper upper case letters - word "word" characters (same as \\w) + word "word" characters (same as \w) xdigit hexadecimal digits

The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13), and space (32). Notice that this list includes the VT character (code 11). This -makes "space" different to \\s, which does not include VT (for Perl +makes "space" different to \s, which does not include VT (for Perl compatibility).

The name "word" is a Perl extension, and "blank" is a GNU extension @@ -1936,7 +1936,7 @@ match. Suppose you want to match the name of a weekday, either as a 3-letter abbreviation or as the full name, and in both cases you want to extract the abbreviation. This pattern (ignoring the line breaks) does the job:

- + (?<DN>Mon|Fri|Sun)(?:day)?| (?<DN>Tue)(?:sday)?| (?<DN>Wed)(?:nesday)?| @@ -1972,12 +1972,12 @@ following items:

a literal data character the dot metacharacter - the \\C escape sequence - the \\X escape sequence + the \C escape sequence + the \X escape sequence (in UTF-8 mode with Unicode properties) - the \\R escape sequence - an escape such as \\d that matches a single character + the \R escape sequence + an escape such as \d that matches a single character a character class a back reference (see next section) a parenthesized subpattern (unless it is an assertion) @@ -1999,7 +1999,7 @@ quantifier specifies an exact number of required matches. Thus

matches at least 3 successive vowels, but may match many more, while

-

\\d{8}

+

\d{8}

matches exactly 8 digits. An opening curly bracket that appears in a position where a quantifier is not allowed, or one that does not match the syntax of a @@ -2007,9 +2007,9 @@ quantifier, is taken as a literal character. For example, {,6} is not a quantifier, but a literal string of four characters.

In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to individual -bytes. Thus, for example, \\x{100}{2} matches two UTF-8 characters, each of +bytes. Thus, for example, \x{100}{2} matches two UTF-8 characters, each of which is represented by a two-byte sequence. Similarly, when Unicode property -support is available, \\X{3} matches three Unicode extended sequences, each of +support is available, \X{3} matches three Unicode extended sequences, each of which may be several bytes long (and they may be of different lengths).

The quantifier {0} is permitted, causing the expression to behave as if the @@ -2042,7 +2042,7 @@ is in trying to match comments in C programs. These appear between /* and */ and within the comment, individual * and / characters may appear. An attempt to match C comments by applying the pattern

-

/\\*.*\\*/

+

/\*.*\*/

to the string

@@ -2055,14 +2055,14 @@ item.

greedy, and instead matches the minimum number of times possible, so the pattern

-

/\\*.*?\\*/

+

/\*.*?\*/

does the right thing with the C comments. The meaning of the various quantifiers is not otherwise changed, just the preferred number of matches. Do not confuse this use of question mark with its use as a quantifier in its own right. Because it has two uses, it can sometimes appear doubled, as in

-

\\d??\\d

+

\d??\d

which matches one digit by preference, but can match two if that is the only way the rest of the pattern matches.

@@ -2081,7 +2081,7 @@ to Perl's /s) is set, thus allowing the dot to match newlines, the pattern is implicitly anchored, because whatever follows will be tried against every character position in the subject string, so there is no point in retrying the overall match at any position after the first. PCRE normally treats such a -pattern as though it were preceded by \\A.

+pattern as though it were preceded by \A.

In cases where it is known that the subject string contains no newlines, it is worth setting dotall in order to obtain this optimization, or @@ -2092,7 +2092,7 @@ is inside capturing parentheses that are the subject of a backreference elsewhere in the pattern, a match at the start may fail where a later one succeeds. Consider, for example:

-

(.*)abc\\1

+

(.*)abc\1

If the subject is "xyz123abc123" the match point is the fourth character. For this reason, such a pattern is not implicitly anchored.

@@ -2100,7 +2100,7 @@ this reason, such a pattern is not implicitly anchored.

When a capturing subpattern is repeated, the value captured is the substring that matched the final iteration. For example, after

-

(tweedle[dume]{3}\\s*)+

+

(tweedle[dume]{3}\s*)+

has matched "tweedledum tweedledee" the value of the captured substring is "tweedledee". However, if there are nested capturing subpatterns, the @@ -2123,12 +2123,12 @@ pattern to match. Sometimes it is useful to prevent this, either to change the nature of the match, or to cause it fail earlier than it otherwise might, when the author of the pattern knows there is no point in carrying on.

-

Consider, for example, the pattern \\d+foo when applied to the subject line

+

Consider, for example, the pattern \d+foo when applied to the subject line

123456bar

After matching all 6 digits and then failing to match "foo", the normal -action of the matcher is to try again with only 5 digits matching the \\d+ +action of the matcher is to try again with only 5 digits matching the \d+ item, and then with 4, and so on, before ultimately failing. "Atomic grouping" (a term taken from Jeffrey Friedl's book) provides the means for specifying that once a subpattern has matched, it is not to be re-evaluated in this way.

@@ -2137,7 +2137,7 @@ that once a subpattern has matched, it is not to be re-evaluated in this way.

-

(?>\\d+)foo

+

(?>\d+)foo

This kind of parenthesis "locks up" the part of the pattern it contains once it has matched, and a failure further into the pattern is prevented from @@ -2150,9 +2150,9 @@ the current point in the subject string.

Atomic grouping subpatterns are not capturing subpatterns. Simple cases such as the above example can be thought of as a maximizing repeat that must swallow -everything it can. So, while both \\d+ and \\d+? are prepared to adjust the +everything it can. So, while both \d+ and \d+? are prepared to adjust the number of digits they match in order to make the rest of the pattern match, -(?>\\d+) can only match an entire sequence of digits.

+(?>\d+) can only match an entire sequence of digits.

Atomic groups in general can of course contain arbitrarily complicated subpatterns, and can be nested. However, when the subpattern for an atomic @@ -2161,7 +2161,7 @@ notation, called a "possessive quantifier" can be used. This consists of an additional + character following a quantifier. Using this notation, the previous example can be rewritten as

-

\\d++foo

+

\d++foo

Note that a possessive quantifier can be used with an entire group, for example:

@@ -2189,7 +2189,7 @@ be repeated an unlimited number of times, the use of an atomic group is the only way to avoid some failing matches taking a very long time indeed. The pattern

-

(\\D+|<\\d+>)*[!?]

+

(\D+|<\d+>)*[!?]

matches an unlimited number of substrings that either consist of non-digits, or digits enclosed in <>, followed by either ! or ?. When it matches, it runs @@ -2198,7 +2198,7 @@ quickly. However, if it is applied to

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

it takes a long time before reporting failure. This is because the string can -be divided between the internal \\D+ repeat and the external * repeat in a +be divided between the internal \D+ repeat and the external * repeat in a large number of ways, and all have to be tried. (The example uses [!?] rather than a single character at the end, because both PCRE and Perl have an optimization that allows for fast failure when a single character is used. They @@ -2206,7 +2206,7 @@ remember the last single character that is required for a match, and fail early if it is not present in the string.) If the pattern is changed so that it uses an atomic group, like this:

-

((?>\\D+)|<\\d+>)*[!?]

+

((?>\D+)|<\d+>)*[!?]

sequences of non-digits cannot be broken, and failure happens quickly.

@@ -2229,22 +2229,22 @@ in an earlier iteration.

It is not possible to have a numerical "forward back reference" to a subpattern whose number is 10 or more using this syntax because a -sequence such as \\50 is interpreted as a character defined in +sequence such as \50 is interpreted as a character defined in octal. See the subsection entitled "Non-printing characters" above for further details of the handling of digits following a backslash. There is no such problem when named parentheses are used. A back reference to any subpattern is possible using named parentheses (see below).

Another way of avoiding the ambiguity inherent in the use of digits -following a backslash is to use the \\g escape sequence, which is a +following a backslash is to use the \g escape sequence, which is a feature introduced in Perl 5.10. This escape must be followed by an unsigned number or a negative number, optionally enclosed in braces. These examples are all identical:

- (ring), \\1 - (ring), \\g1 - (ring), \\g{1} + (ring), \1 + (ring), \g1 + (ring), \g{1}

An unsigned number specifies an absolute reference without the @@ -2252,11 +2252,11 @@ ambiguity that is present in the older syntax. It is also useful when literal digits follow the reference. A negative number is a relative reference. Consider this example:

-

(abc(def)ghi)\\g{-1}

+

(abc(def)ghi)\g{-1}

-

The sequence \\g{-1} is a reference to the most recently started capturing -subpattern before \\g, that is, is it equivalent to \\2. Similarly, \\g{-2} -would be equivalent to \\1. The use of relative references can be helpful in +

The sequence \g{-1} is a reference to the most recently started capturing +subpattern before \g, that is, is it equivalent to \2. Similarly, \g{-2} +would be equivalent to \1. The use of relative references can be helpful in long patterns, and also in patterns that are created by joining together fragments that contain references within themselves.

@@ -2265,29 +2265,29 @@ subpattern in the current subject string, rather than anything matching the subpattern itself (see "Subpatterns as subroutines" below for a way of doing that). So the pattern

-

(sens|respons)e and \\1ibility

+

(sens|respons)e and \1ibility

matches "sense and sensibility" and "response and responsibility", but not "sense and responsibility". If caseful matching is in force at the time of the back reference, the case of letters is relevant. For example,

-

((?i)rah)\\s+\\1

+

((?i)rah)\s+\1

matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original capturing subpattern is matched caselessly.

There are several different ways of writing back references to named -subpatterns. The .NET syntax \\k{name} and the Perl syntax \\k<name> or -\\k'name' are supported, as is the Python syntax (?P=name). Perl 5.10's unified -back reference syntax, in which \\g can be used for both numeric and named +subpatterns. The .NET syntax \k{name} and the Perl syntax \k<name> or +\k'name' are supported, as is the Python syntax (?P=name). Perl 5.10's unified +back reference syntax, in which \g can be used for both numeric and named references, is also supported. We could rewrite the above example in any of the following ways:

- (?<p1>(?i)rah)\\s+\\k<p1> - (?'p1'(?i)rah)\\s+\\k{p1} - (?P<p1>(?i)rah)\\s+(?P=p1) - (?<p1>(?i)rah)\\s+\\g{p1} + (?<p1>(?i)rah)\s+\k<p1> + (?'p1'(?i)rah)\s+\k{p1} + (?P<p1>(?i)rah)\s+(?P=p1) + (?<p1>(?i)rah)\s+\g{p1}

A subpattern that is referenced by name may appear in the pattern before or @@ -2297,7 +2297,7 @@ after the reference.

subpattern has not actually been used in a particular match, any back references to it always fail. For example, the pattern

-

(a|(bc))\\2

+

(a|(bc))\2

always fails if it starts to match "a" rather than "bc". Because there may be many capturing parentheses in a pattern, all digits @@ -2308,11 +2308,11 @@ some delimiter must be used to terminate the back reference. If the empty comment (see "Comments" below) can be used.

A back reference that occurs inside the parentheses to which it refers fails -when the subpattern is first used, so, for example, (a\\1) never matches. +when the subpattern is first used, so, for example, (a\1) never matches. However, such references can be useful inside repeated subpatterns. For example, the pattern

-

(a|b\\1)+

+

(a|b\1)+

matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of the subpattern, the back reference matches the character string corresponding @@ -2327,7 +2327,7 @@ minimum of zero.

An assertion is a test on the characters following or preceding the current matching point that does not actually consume any characters. The simple -assertions coded as \\b, \\B, \\A, \\G, \\Z, \\z, ^ and $ are described +assertions coded as \b, \B, \A, \G, \Z, \z, ^ and $ are described above.

@@ -2348,7 +2348,7 @@ because it does not make sense for negative assertions.

Lookahead assertions start with (?= for positive assertions and (?! for negative assertions. For example,

-

\\w+(?=;)

+

\w+(?=;)

matches a word followed by a semicolon, but does not include the semicolon in the match, and

@@ -2400,7 +2400,7 @@ lengths, but it is acceptable if rewritten to use two top-level branches:

(?<=abc|abde)

-

In some cases, the Perl 5.10 escape sequence \\K (see above) can be +

In some cases, the Perl 5.10 escape sequence \K (see above) can be used instead of a lookbehind assertion; this is not restricted to a fixed-length.

@@ -2409,9 +2409,9 @@ temporarily move the current position back by the fixed length and then try to match. If there are insufficient characters before the current position, the assertion fails.

-

PCRE does not allow the \\C escape (which matches a single byte in UTF-8 mode) +

PCRE does not allow the \C escape (which matches a single byte in UTF-8 mode) to appear in lookbehind assertions, because it makes it impossible to calculate -the length of the lookbehind. The \\X and \\R escapes, which can match +the length of the lookbehind. The \X and \R escapes, which can match different numbers of bytes, are also not permitted.

Possessive quantifiers can be used in conjunction with lookbehind assertions to @@ -2443,7 +2443,7 @@ approach makes a significant difference to the processing time.

Several assertions (of any sort) may occur in succession. For example,

-

(?<=\\d{3})(?<!999)foo

+

(?<=\d{3})(?<!999)foo

matches "foo" preceded by three digits that are not "999". Notice that each of the assertions is applied independently at the same point @@ -2454,7 +2454,7 @@ three characters are not "999". This pattern does not match the last three of which are not "999". For example, it doesn't match "123abcfoo". A pattern to do that is

-

(?<=\\d{3}...)(?<!999)foo

+

(?<=\d{3}...)(?<!999)foo

This time the first assertion looks at the preceding six characters, checking that the first three are digits, and then the @@ -2468,7 +2468,7 @@ second assertion checks that the preceding three characters are not

matches an occurrence of "baz" that is preceded by "bar" which in turn is not preceded by "foo", while

-

(?<=\\d{3}(?!999)...)foo

+

(?<=\d{3}(?!999)...)foo

is another pattern that matches "foo" preceded by three digits and any three characters that are not "999".

@@ -2510,7 +2510,7 @@ refer to subsequent groups with constructs such as (?(+2).

whitespace to make it more readable (assume the extended option) and to divide it into three parts for ease of discussion:

-

( \\( )? [^()]+ (?(1) \\) )

+

( \( )? [^()]+ (?(1) \) )

The first part matches an optional opening parenthesis, and if that character is present, sets it as the first captured substring. The second part @@ -2525,7 +2525,7 @@ non-parentheses, optionally enclosed in parentheses.

If you were embedding this pattern in a larger one, you could use a relative reference:

-

...other stuff... ( \\( )? [^()]+ (?(-1) \\) ) ...

+

...other stuff... ( \( )? [^()]+ (?(-1) \) ) ...

This makes the fragment independent of the parentheses in the larger pattern.

@@ -2543,7 +2543,7 @@ consist entirely of digits is not recommended.

Rewriting the above example to use a named subpattern gives this:

-

(?<OPEN> \\( )? [^()]+ (?(<OPEN>) \\) )

+

(?<OPEN> \( )? [^()]+ (?(<OPEN>) \) )

Checking for pattern recursion

@@ -2571,8 +2571,8 @@ point in the pattern; the idea of DEFINE is that it can be used to define is described below.) For example, a pattern to match an IPv4 address could be written like this (ignore whitespace and line breaks):

-

(?(DEFINE) (?<byte> 2[0-4]\\d | 25[0-5] | 1\\d\\d | [1-9]?\\d) ) - \\b (?&byte) (\\.(?&byte)){3} \\b

+

(?(DEFINE) (?<byte> 2[0-4]\d | 25[0-5] | 1\d\d | [1-9]?\d) ) + \b (?&byte) (\.(?&byte)){3} \b

The first part of the pattern is a DEFINE group inside which a another group named "byte" is defined. This matches an individual component of an IPv4 @@ -2590,9 +2590,9 @@ assertion. This may be a positive or negative lookahead or lookbehind assertion. Consider this pattern, again containing non-significant whitespace, and with the two alternatives on the second line:

- + (?(?=[^a-z]*[a-z]) - \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) + \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )

The condition is a positive lookahead assertion that matches an optional sequence of non-letters followed by a letter. In other words, it tests for the @@ -2631,7 +2631,7 @@ can refer to the expression itself. A Perl pattern using code interpolation to solve the parentheses problem can be created like this:

-

$re = qr{\\( (?: (?>[^()]+) | (?p{$re}) )* \\)}x;

+

$re = qr{\( (?: (?>[^()]+) | (?p{$re}) )* \)}x;

The (?p{...}) item interpolates Perl code at run time, and in this case refers recursively to the pattern in which it appears.

@@ -2657,7 +2657,7 @@ failure.

This PCRE pattern solves the nested parentheses problem (assume the extended option is set so that whitespace is ignored):

-

\\( ( (?>[^()]+) | (?R) )* \\)

+

\( ( (?>[^()]+) | (?R) )* \)

First it matches an opening parenthesis. Then it matches any number of substrings which can either be a sequence of non-parentheses, or a @@ -2667,7 +2667,7 @@ parenthesized substring). Finally there is a closing parenthesis.

If this were part of a larger pattern, you would not want to recurse the entire pattern, so instead you could use this:

-

( \\( ( (?>[^()]+) | (?1) )* \\) )

+

( \( ( (?>[^()]+) | (?1) )* \) )

We have put the pattern into parentheses, and caused the recursion to refer to them instead of the whole pattern.

@@ -2691,7 +2691,7 @@ Perl syntax for this is (?&name); PCRE's earlier syntax (?P>name) is also supported. We could rewrite the above example as follows:

-

(?<pn> \\( ( (?>[^()]+) | (?&pn) )* \\) )

+

(?<pn> \( ( (?>[^()]+) | (?&pn) )* \) )

If there is more than one subpattern with the same name, the earliest one is used.

@@ -2727,7 +2727,7 @@ If the pattern above is matched against

on at the top level. If additional parentheses are added, giving

- \\( ( ( (?>[^()]+) | (?R) )* ) \\) + \( ( ( (?>[^()]+) | (?R) )* ) \) ^ ^ ^ ^ @@ -2747,7 +2747,7 @@ brackets, allowing for arbitrary nesting. Only digits are allowed in nested brackets (that is, when recursing), whereas any characters are permitted at the outer level.

-

< (?: (?(R) \\d++ | [^<>]*+) | (?R)) * >

+

< (?: (?(R) \d++ | [^<>]*+) | (?R)) * >

In this pattern, (?(R) is the start of a conditional subpattern, with two different alternatives for the recursive and non-recursive @@ -2771,7 +2771,7 @@ relative, as in these examples:

An earlier example pointed out that the pattern

-

(sens|respons)e and \\1ibility

+

(sens|respons)e and \1ibility

matches "sense and sensibility" and "response and responsibility", but not "sense and responsibility". If instead the pattern

diff --git a/lib/stdlib/doc/src/regexp.xml b/lib/stdlib/doc/src/regexp.xml index 8da636e4ad..8c4191c88f 100644 --- a/lib/stdlib/doc/src/regexp.xml +++ b/lib/stdlib/doc/src/regexp.xml @@ -132,7 +132,7 @@ RepCount = integer() -

Substitutes the first occurrence of a substring matching RegExp in String with the string New. A in the string New is replaced by the matched substring of String. puts a literal into the replacement string. It returns as follows:

+

Substitutes the first occurrence of a substring matching RegExp in String with the string New. A in the string New is replaced by the matched substring of String. puts a literal into the replacement string. It returns as follows:

{ok,NewString,RepCount} @@ -286,7 +286,7 @@

matches the non-metacharacter c.

- \\c + \c

matches the escape sequence or literal character c.

@@ -341,74 +341,74 @@

The escape sequences allowed are the same as for Erlang strings:

- \\b + \b

backspace

- \\f + \f

form feed

- \ + \n

newline (line feed)

- \\r + \r

carriage return

- \\t + \t

tab

- \\e + \e

escape

- \\v + \v

vertical tab

- \\s + \s

space

- \\d + \d

delete

- \\ddd + \ddd

the octal value ddd

- \\xhh + \xhh

The hexadecimal value hh.

- \\x{h...} + \x{h...}

The hexadecimal value h....

- \\c + \c -

any other character literally, for example \\\\ for backslash, - \\" for ")

+

any other character literally, for example \\ for backslash, + \" for ")

To make these functions easier to use, in combination with the function io:get_line which terminates the input line with a new line, the $ characters also matches a string ending - with "...\ ". The following examples + with "...\n". The following examples define Erlang data types:

 Atoms     [a-z][0-9a-zA-Z_]*
 
 Variables [A-Z_][0-9a-zA-Z_]*
 
-Floats    (\\+|-)?[0-9]+\\.[0-9]+((E|e)(\\+|-)?[0-9]+)?
-

Regular expressions are written as Erlang strings when used with the functions in this module. This means that any \\ or " characters in a regular expression - string must be written with \\ as they are also escape characters for the string. For example, the regular expression string for Erlang floats is: - "(\\\\+|-)?[0-9]+\\\\.[0-9]+((E|e)(\\\\+|-)?[0-9]+)?".

+Floats (\+|-)?[0-9]+\.[0-9]+((E|e)(\+|-)?[0-9]+)? +

Regular expressions are written as Erlang strings when used with the functions in this module. This means that any \ or " characters in a regular expression + string must be written with \ as they are also escape characters for the string. For example, the regular expression string for Erlang floats is: + "(\\+|-)?[0-9]+\\.[0-9]+((E|e)(\\+|-)?[0-9]+)?".

It is not really necessary to have the escape sequences as part of the regular expression syntax as they can always be generated directly in the string. They are included for completeness and can they can also be useful when generating regular expressions, or when they are entered other than with Erlang strings.

diff --git a/lib/stdlib/doc/src/shell.xml b/lib/stdlib/doc/src/shell.xml index 24b845fee9..b8fc64f45e 100644 --- a/lib/stdlib/doc/src/shell.xml +++ b/lib/stdlib/doc/src/shell.xml @@ -333,10 +333,12 @@ undefined <0.57.0> 27> get(aa). hello -28> io:format("hello hello\ "). -hello hello ok +28> io:format("hello hello\n"). +hello hello +ok 29> e(28). -hello hello ok +hello hello +ok 30> v(28). ok 31> c(ex). diff --git a/lib/stdlib/doc/src/string.xml b/lib/stdlib/doc/src/string.xml index 7ee38e496d..de1b99a2d5 100644 --- a/lib/stdlib/doc/src/string.xml +++ b/lib/stdlib/doc/src/string.xml @@ -117,9 +117,9 @@ from) Chars.

For example:

-> string:span("\\t abcdef", " \\t"). +> string:span("\t abcdef", " \t"). 5 -> string:cspan("\\t abcdef", " \\t"). +> string:cspan("\t abcdef", " \t"). 0 diff --git a/lib/stdlib/doc/src/win32reg.xml b/lib/stdlib/doc/src/win32reg.xml index d8055047b0..28960cd098 100644 --- a/lib/stdlib/doc/src/win32reg.xml +++ b/lib/stdlib/doc/src/win32reg.xml @@ -48,7 +48,7 @@

Paths to keys are left to right, with sub-keys to the right and backslash between keys. (Remember that backslashes must be doubled in Erlang strings.) Case is preserved but not significant. - Example: "\\\\hkey_local_machine\\\\software\\\\Ericsson\\\\Erlang\\\\5.0" is the key + Example: "\\hkey_local_machine\\software\\Ericsson\\Erlang\\5.0" is the key for the installation data for the latest Erlang release.

There are six entry points in the Windows registry, top level keys. They can be abbreviated in the win32reg module as:

@@ -66,7 +66,7 @@ current_config HKEY_CURRENT_CONFIG hkcc HKEY_CURRENT_CONFIG dyn_data HKEY_DYN_DATA hkdd HKEY_DYN_DATA -

The key above could be written as "\\\\hklm\\\\software\\\\ericsson\\\\erlang\\\\5.0".

+

The key above could be written as "\\hklm\\software\\ericsson\\erlang\\5.0".

The win32reg module uses a current key. It works much like the current directory. From the current key, values can be fetched, sub-keys can be listed, and so on.

@@ -96,7 +96,7 @@ hkdd HKEY_DYN_DATA

Changes the current key to another key. Works like cd. The key can be specified as a relative path or as an - absolute path, starting with \\.

+ absolute path, starting with \.

-- cgit v1.2.3