=encoding euc-jp =head1 NAME =begin original perlrebackslash - Perl Regular Expression Backslash Sequences and Escapes =end original perlrebackslash - Perl ����ɽ���ե���å��奷�����󥹤ȥ��������� =head1 DESCRIPTION =begin original The top level documentation about Perl regular expressions is found in L. =end original Perl ����ɽ���˴ؤ���Ǿ��ʸ��� L �Ǥ��� =begin original This document describes all backslash and escape sequences. After explaining the role of the backslash, it lists all the sequences that have a special meaning in Perl regular expressions (in alphabetical order), then describes each of them. =end original ����ʸ������Ƥεե���å��奷�����󥹤ȥ��������ץ������󥹤ˤĤ��� ���Ҥ��ޤ��� �ե���å�������ˤĤ��������������ȡ�Perl ����ɽ����������̤ʰ�̣����� ���ƤΥ������󥹤�(����ե��٥åȽ��)���������줾��ˤĤ��Ƶ��Ҥ��ޤ��� =begin original Most sequences are described in detail in different documents; the primary purpose of this document is to have a quick reference guide describing all backslash and escape sequences. =end original �ۤȤ�ɤΥ������󥹤�¾��ʸ��˾ܺ٤˵��Ҥ���Ƥ��ޤ�; ����ʸ��μ����Ū�� ���Ƥεե���å��奷�����󥹤ȥ��������ץ������󥹤򵭽Ҥ��� �����å���ե���󥹥����ɤȤʤ뤳�ȤǤ��� =head2 The backslash (�ե���å���) =begin original In a regular expression, the backslash can perform one of two tasks: it either takes away the special meaning of the character following it (for instance, C<\|> matches a vertical bar, it's not an alternation), or it is the start of a backslash or escape sequence. =end original ����ɽ���ˤ����ơ��ե���å������ĤΥ������Τɤ��餫��Ԥ��ޤ�: ����³��ʸ�����ü�ʰ�̣�������(�㤨�С�(C<\|> �����ؤǤϤʤ�����ľ�С��� �ޥå��󥰤��ޤ�)�����ե���å��奷�����󥹤ޤ��ϥ��������ץ������󥹤� ���ϤȤʤ�ޤ��� =begin original The rules determining what it is are quite simple: if the character following the backslash is an ASCII punctuation (non-word) character (that is, anything that is not a letter, digit, or underscore), then the backslash just takes away any special meaning of the character following it. =end original ���줬��������ꤹ�뵬§�Ϥ��ʤ�ñ��Ǥ�: �ե���å���˰���³��ʸ���� ASCII ������(��ñ��)ʸ��(����ϱѻ��������������ʳ������Ƥ�ʸ��)�ʤ顢 �ե���å���ϰ���³��ʸ�������̤ʰ�̣��������ޤ��� =begin original If the character following the backslash is an ASCII letter or an ASCII digit, then the sequence may be special; if so, it's listed below. A few letters have not been used yet, so escaping them with a backslash doesn't change them to be special. A future version of Perl may assign a special meaning to them, so if you have warnings turned on, Perl issues a warning if you use such a sequence. [1]. =end original �ե���å���˰���³��ʸ���� ASCII �ѻ��ޤ��� ASCII �����ʤ顢�����¤Ӥ� ���̤Ǥ�; ���ξ�硢�ʲ��˼����ޤ��� �����Ĥ���ʸ���Ϥޤ��Ȥ��Ƥ��餺�������ե���å���ǥ��������פ���Τ� ���̤ʤ�ΤˤϤ��ޤ��� ����ΥС������� Perl �Ϥ�������̤ʰ�̣�������Ƥ뤫�⤷��ʤ��Τǡ� ���������ٹ�ͭ���ʤ顢���Τ褦���¤Ӥ�Ȥ��� Perl �Ϸٹ����Ϥ��ޤ��� [1]�� =begin original It is however guaranteed that backslash or escape sequences never have a punctuation character following the backslash, not now, and not in a future version of Perl 5. So it is safe to put a backslash in front of a non-word character. =end original ���������ե���å��奷�����󥹤䥨�������ץ������󥹤��ե���å���θ�� ������ʸ�������뤳�Ȥ��ʤ����ȤϺ������ǤϤʤ�����ΥС������� Perl 5 �Ǥ��ݾڤ���Ƥ��ޤ��� ���äơ���ñ��ʸ�������˵ե���å�����֤��Τϰ����Ǥ��� =begin original Note that the backslash itself is special; if you want to match a backslash, you have to escape the backslash with a backslash: C matches a single backslash. =end original �ե���å��弫�Τ����̤Ǥ��뤳�Ȥ����դ��Ƥ�������; �ե���å���� �ޥå��󥰤������ʤ顢�ե���å����ե���å���ǥ��������פ���ɬ�פ� ����ޤ�: C ��ñ��εե���å���˥ޥå��󥰤��ޤ��� =over 4 =item [1] =begin original There is one exception. If you use an alphanumeric character as the delimiter of your pattern (which you probably shouldn't do for readability reasons), you have to escape the delimiter if you want to match it. Perl won't warn then. See also L. =end original ��Ĥ��㳰������ޤ��� �ѥ�����ζ��ڤ�Ȥ��Ʊѿ�����ȤäƤ���(�����餯����ϲ���������ͳ�� ����٤��ǤϤ���ޤ���)��硢����ʸ���˥ޥå��󥰤������ʤ���ڤ�ʸ���� ���������פ���ɬ�פ�����ޤ��� Perl �Ϸٹ��Ф��ޤ��� L �⻲�Ȥ��Ƥ��������� =back =head2 All the sequences and escapes (���ƤΥ������󥹤ȥ���������) =begin original Those not usable within a bracketed character class (like C<[\da-z]>) are marked as C =end original (C<[\da-z]> �Τ褦��) �礫�ä�ʸ�����饹�ǻȤ��ʤ���Τ� C<[] ��ǤϻȤ��ʤ���> �ȵ����Ƥ��ޤ��� =begin original \000 Octal escape sequence. See also \o{}. \1 Absolute backreference. Not in []. \a Alarm or bell. \A Beginning of string. Not in []. \b Word/non-word boundary. (Backspace in []). \B Not a word/non-word boundary. Not in []. \cX Control-X \C Single octet, even under UTF-8. Not in []. \d Character class for digits. \D Character class for non-digits. \e Escape character. \E Turn off \Q, \L and \U processing. Not in []. \f Form feed. \F Foldcase till \E. Not in []. \g{}, \g1 Named, absolute or relative backreference. Not in [] \G Pos assertion. Not in []. \h Character class for horizontal whitespace. \H Character class for non horizontal whitespace. \k{}, \k<>, \k'' Named backreference. Not in []. \K Keep the stuff left of \K. Not in []. \l Lowercase next character. Not in []. \L Lowercase till \E. Not in []. \n (Logical) newline character. \N Any character but newline. Experimental. Not in []. \N{} Named or numbered (Unicode) character or sequence. \o{} Octal escape sequence. \p{}, \pP Character with the given Unicode property. \P{}, \PP Character without the given Unicode property. \Q Quote (disable) pattern metacharacters till \E. Not in []. \r Return character. \R Generic new line. Not in []. \s Character class for whitespace. \S Character class for non whitespace. \t Tab character. \u Titlecase next character. Not in []. \U Uppercase till \E. Not in []. \v Character class for vertical whitespace. \V Character class for non vertical whitespace. \w Character class for word characters. \W Character class for non-word characters. \x{}, \x00 Hexadecimal escape sequence. \X Unicode "extended grapheme cluster". Not in []. \z End of string. Not in []. \Z End of string. Not in []. =end original \000 8 �ʿ����������ץ������󥹡�\o{} �⻲�ȡ� \1 ���и������ȡ�[] ��ǤϻȤ��ʤ��� \a ���顼��ޤ��ϥ٥롣 \A ʸ�������Ƭ��[] ��ǤϻȤ��ʤ��� \b ñ��/��ñ�춭����([] ��Ǥϸ���)�� \B ñ��/��ñ�춭���Ǥʤ���[] ��ǤϻȤ��ʤ��� \cX Control-X \C UTF-8 �β��Ǥ⡢ñ��Υ����ƥåȡ�[] ��ǤϻȤ��ʤ��� \d �����Τ����ʸ�����饹�� \D ������Τ����ʸ�����饹�� \e ����������ʸ���� \E \Q, \L, \U �ν�����λ���롣[] ��ǤϻȤ��ʤ��� \f �����ꡣ \F \E �ޤǾ��߹���ʸ����[] ��ǤϻȤ��ʤ��� \g{}, \g1 ̾���դ������Фޤ������и������ȡ�[] ��ǤϻȤ��ʤ��� \G ����ɽ����[] ��ǤϻȤ��ʤ��� \h ��ʿ����Τ����ʸ�����饹�� \H ���ʿ����Τ����ʸ�����饹�� \k{}, \k<>, \k'' ̾���դ��������ȡ�[] ��ǤϻȤ��ʤ��� \K \K �κ�¦���ݻ����롣[] ��ǤϻȤ��ʤ��� \l ����ʸ����ʸ���ˡ�[] ��ǤϻȤ��ʤ��� \L \E �ޤǾ�ʸ���ˡ�[] ��ǤϻȤ��ʤ��� \n (����) ����ʸ���� \N ���԰ʳ���Ǥ�դ�ʸ�����¸�Ū��[] ��ǤϻȤ��ʤ��� \N{} ̾���դ��ޤ����ֹ� (Unicode) ʸ���ޤ����¤ӡ� \o{} 8 �ʿ����������ץ������󥹡� \p{}, \pP Unicode �����դ�ʸ���� \P{}, \PP Unicode �����ʤ�ʸ���� \Q \E �ޤǥѥ�����᥿ʸ���򥯥�����(̵����)�� [] ��ǤϻȤ��ʤ��� \r ����ʸ���� \R ����Ū�ʲ��ԡ�[] ��ǤϻȤ��ʤ��� \s ����Τ����ʸ�����饹�� \S �����Τ����ʸ�����饹�� \t ����ʸ���� \u �Ԥ�ʸ���򥿥��ȥ�ʸ���ˡ�[] ��ǤϻȤ��ʤ��� \U \E �ޤ���ʸ���ˡ�[] ��ǤϻȤ��ʤ��� \v ��ľ�Τ����ʸ�����饹�� \V ���ľ����Τ����ʸ�����饹�� \w ñ��ʸ����ʸ�����饹�� \W ��ñ��ʸ���Τ����ʸ�����饹�� \x{}, \x00 16 �ʿ����������ץ������󥹡� \X �ֳ�ĥ���ǥ��饹���ס�[] ��ǤϻȤ��ʤ��� \z ʸ�����������[] ��ǤϻȤ��ʤ��� \Z ʸ�����������[] ��ǤϻȤ��ʤ��� =head2 Character Escapes (ʸ������������) =head3 Fixed characters (����ʸ��) =begin original A handful of characters have a dedicated I. The following table shows them, along with their ASCII code points (in decimal and hex), their ASCII name, the control escape on ASCII platforms and a short description. (For EBCDIC platforms, see L.) =end original ������ʸ����� I<ʸ������������> �Ȥ���ư��ޤ��� �����ϡ�ASCII ������ (10 �ʤ� 16 ��)��ASCII ��̾����ASCII �ץ�åȥե�����Ǥ����楨�������ס�û�������ȶ��ˡ��ʲ���ɽ�˼����Ƥ��ޤ��� (EBCDIC �ץ�åȥե�����ˤĤ��Ƥϡ�L �� ���Ȥ��Ƥ���������) =begin original Seq. Code Point ASCII Cntrl Description. Dec Hex \a 7 07 BEL \cG alarm or bell \b 8 08 BS \cH backspace [1] \e 27 1B ESC \c[ escape character \f 12 0C FF \cL form feed \n 10 0A LF \cJ line feed [2] \r 13 0D CR \cM carriage return \t 9 09 TAB \cI tab =end original Seq. ������ ASCII Cntrl ������ 10 �� 16 �� \a 7 07 BEL \cG ���顼��ޤ��ϥ٥� \b 8 08 BS \cH ���� [1] \e 27 1B ESC \c[ ����������ʸ�� \f 12 0C FF \cL ������ \n 10 0A LF \cJ ���� [2] \r 13 0D CR \cM ���� \t 9 09 TAB \cI ���� =over 4 =item [1] =begin original C<\b> is the backspace character only inside a character class. Outside a character class, C<\b> is a word/non-word boundary. =end original C<\b> ��ʸ�����饹����ǤΤ�����ʸ���Ǥ��� ʸ�����饹�γ�¦�Ǥϡ�C<\b> ��ñ����ñ�춭���Ǥ��� =item [2] =begin original C<\n> matches a logical newline. Perl converts between C<\n> and your OS's native newline character when reading from or writing to text files. =end original C<\n> ���������Ԥ˥ޥå��󥰤��ޤ��� Perl �ϥƥ����ȥե�������ɤ߽񤭤򤹤���ˤ� C<\n> OS �ͥ��ƥ��֤� ����ʸ���Ȥδ֤��Ѵ����ޤ��� =back =head4 Example (��) $str =~ /\t/; # Matches if $str contains a (horizontal) tab. =head3 Control characters (����ʸ��) =begin original C<\c> is used to denote a control character; the character following C<\c> determines the value of the construct. For example the value of C<\cA> is C, and the value of C<\cb> is C, etc. The gory details are in L. A complete list of what C, etc. means for ASCII and EBCDIC platforms is in L. =end original C<\c> ������ʸ���򼨤�����˻Ȥ��ޤ�; C<\c> �˰���³��ʸ���� ��ʸ���ͤ���ꤷ�ޤ��� �㤨�� C<\cA> ���ͤ� C��C<\cb> ���ͤ� C���ʤɤǤ��� �����ξܺ٤� L �ˤ���ޤ��� ASCII �� EBCDIC �ץ�åȥե������ C �ʤɤ���̣�����Τδ����� ������ L �ˤ���ޤ��� =begin original Note that C<\c\> alone at the end of a regular expression (or doubled-quoted string) is not valid. The backslash must be followed by another character. That is, C<\c\I> means C'> for all characters I. =end original ����ɽ�� (�ޤ��ϥ��֥륯�����Ȥ��줿ʸ����) ��������ñ�Τ� C<\c\> ���֤��Τ� �����Ǥ��� �ե���å���ˤ�¾��ʸ��������³���ʤ���Фʤ�ޤ��� �Ĥޤꡢ���Ƥ�ʸ�� I ���Ф��� C<\c\I> �� C' ���̣����> �Ȥ������ȤǤ��� =begin original To write platform-independent code, you must use C<\N{I}> instead, like C<\N{ESCAPE}> or C<\N{U+001B}>, see L. =end original �ץ�åȥե�������Ω�ʥ����ɤ�񤯤���ˤϡ������ C<\N{ESCAPE}> �� C<\N{U+001B}> �Τ褦�� C<\N{I}> ��Ȥ�ʤ���Фʤ�ޤ���; L �򻲾Ȥ��Ƥ��������� =begin original Mnemonic: Iontrol character. =end original ����ˡ: ����ʸ��(Iontrol character)�� =head4 Example (��) $str =~ /\cK/; # Matches if $str contains a vertical tab (control-K). =head3 Named or numbered characters and character sequences (̾���դ��ޤ����ֹ�ˤ��ʸ�������ʸ���¤�) =begin original Unicode characters have a Unicode name and numeric code point (ordinal) value. Use the C<\N{}> construct to specify a character by either of these values. Certain sequences of characters also have names. =end original Unicode ʸ���� Unicode ̾�ȿ��ͤ�������(����)������ޤ��� ʸ���򤽤����ͤǻ��ꤹ��ˤ� C<\N{}> ��ʸ��Ȥ��ޤ��� ������ʸ���¤Ӥˤ�̾��������ޤ��� =begin original To specify by name, the name of the character or character sequence goes between the curly braces. =end original ̾������ꤹ��ˤϡ�ʸ����ʸ���¤Ӥ�̾�����椫�ä��δ֤˽񤭤ޤ��� =begin original To specify a character by Unicode code point, use the form C<\N{U+I}>, where I is a number in hexadecimal that gives the code point that Unicode has assigned to the desired character. It is customary but not required to use leading zeros to pad the number to 4 digits. Thus C<\N{U+0041}> means C, and you will rarely see it written without the two leading zeros. C<\N{U+0041}> means "A" even on EBCDIC machines (where the ordinal value of "A" is not 0x41). =end original ʸ���� Unicode �����֤ǻ��ꤹ��ˤϡ�C<\N{U+I}> ������Ȥ��ޤ�; ������ I �� Unicode ����Ū��ʸ���˳�����ƤƤ��������֤� 16 �ʿ��ǻ��ꤷ�ޤ��� ���ͤ� 4 ��˥ѥåǥ��󥰤��뤿�����Ƭ�˥������դ��봷��������ޤ����� ɬ�ܤǤϤ���ޤ��� ���ä� C<\N{U+0041}> �� C ���̣������Ƭ����Ĥ� �����ʤ��ǽ񤫤��Τ򸫤뤳�Ȥϵ��Ǥ��礦�� C<\N{U+0041}> �� ("A" �ν����� 0x41 �Ǥʤ�) EBCDIC �ޥ���Ǥ� "A" �� ��̣���ޤ��� =begin original It is even possible to give your own names to characters and character sequences. For details, see L. =end original ʸ����ʸ���¤Ӥ��ȼ���̾����Ĥ��뤳�Ȥ����ǽ�Ǥ��� �ܤ����� L �򻲾Ȥ��Ƥ��������� =begin original (There is an expanded internal form that you may see in debug output: C<\N{U+I.I...}>. The C<...> means any number of these Is separated by dots. This represents the sequence formed by the characters. This is an internal form only, subject to change, and you should not try to use it yourself.) =end original (�ǥХå����ϤǸ��뤫���Τ�ʤ���ĥ�������� C<\N{U+I.I...}> ������ޤ��� C<...> ��Ǥ�դο��� I ��ɥåȤǶ��ڤä���ΤǤ��� �����ʸ���ˤ�äƷ���������¤Ӥ�ɽ�����ޤ��� ����������������Ѥǡ��ѹ�����뤫���Τ줺����ʬ���Ȥ� �Ȥ����Ȥ���٤��ǤϤ���ޤ���) =begin original Mnemonic: Iamed character. =end original ����ˡ: ̾���դ�ʸ��(Iamed character)�� =begin original Note that a character or character sequence expressed as a named or numbered character is considered a character without special meaning by the regex engine, and will match "as is". =end original ̾���դ��ޤ����ֹ�ˤ��ʸ���ޤ���ʸ���¤Ӥ�ɽ�������ʸ���� ����ɽ�����󥸥�ˤȤä����̤ʰ�̣������ʤ�ʸ���Ȥ��ư���졢 �֤��Τޤޡפǥޥå��󥰤��뤳�Ȥ����դ��Ƥ��������� =head4 Example (��) $str =~ /\N{THAI CHARACTER SO SO}/; # Matches the Thai SO SO character use charnames 'Cyrillic'; # Loads Cyrillic names. $str =~ /\N{ZHE}\N{KA}/; # Match "ZHE" followed by "KA". =head3 Octal escapes (8 �ʿ�����������) =begin original There are two forms of octal escapes. Each is used to specify a character by its code point specified in octal notation. =end original 8 �ʿ����������פˤ���Ĥη���������ޤ��� ���줾��� 8 �ʵ�ˡ�ǻ��ꤵ�줿�����֤�ʸ������ꤹ�뤿��˻Ȥ��ޤ��� =begin original One form, available starting in Perl 5.14 looks like C<\o{...}>, where the dots represent one or more octal digits. It can be used for any Unicode character. =end original Perl 5.14 �������Ѳ�ǽ�ˤʤä�����ܤη����� C<\o{...}> �Τ褦�ʤ�Τǡ� �ɥåȤϰ�İʾ�� 8 �ʿ���ɽ�����ޤ��� ����ϤɤΤ褦�� Unicode ʸ���ˤ�Ȥ��ޤ��� =begin original It was introduced to avoid the potential problems with the other form, available in all Perls. That form consists of a backslash followed by three octal digits. One problem with this form is that it can look exactly like an old-style backreference (see L below.) You can avoid this by making the first of the three digits always a zero, but that makes \077 the largest code point specifiable. =end original ��������Ƥ� Perl �����Ѳ�ǽ�ʤ⤦��Ĥη���������Ū��������򤱤뤿��� Ƴ������ޤ����� ���η����ϵե���å���˰���³���� 3 ��� 8 �ʿ��Ǥ��� ���η���������ΰ�Ĥϡ��Ť������θ������ȤȤޤä���Ʊ���褦�˸����뤳�ȤǤ� (�ʲ��� L �򻲾Ȥ��Ƥ���������) 3 ��ο����κǽ��ʸ�����˥����ˤ��뤳�Ȥˤ�����򤱤��ޤ���������Ǥ��� ����������֤� \077 �ˤʤ�ޤ��� =begin original In some contexts, a backslash followed by two or even one octal digits may be interpreted as an octal escape, sometimes with a warning, and because of some bugs, sometimes with surprising results. Also, if you are creating a regex out of smaller snippets concatenated together, and you use fewer than three digits, the beginning of one snippet may be interpreted as adding digits to the ending of the snippet before it. See L for more discussion and examples of the snippet problem. =end original �����Υ���ƥ����ȤǤϡ��ե���å���˰���³������Ĥ��Ĥ� 8 �ʿ��� 8 �ʥ��������פȤ��Ʋ�ᤵ�졢�����ٹ𤬽Фơ������ΥХ��ˤ�ꡢ���� �ä��褦�ʷ�̤ˤʤ�ޤ��� �ޤ�����꾮�������˥ڥåȤ��礷������ɽ����������ơ�3 ���꾮������Τ� �Ȥ��ȡ���ĤΥ��˥ڥåȤκǽ餬�������Υ��˥ڥåȤν������ɲä��줿 ���ͤȲ�ᤵ��뤳�Ȥ�����ޤ��� ���˥ڥå�����˴ؤ��뤵��ʤ��������ˤĤ��Ƥ� L �� ���Ȥ��Ƥ��������� =begin original Note that a character expressed as an octal escape is considered a character without special meaning by the regex engine, and will match "as is". =end original 8 �ʥ��������פ�ɽ�������ʸ��������ɽ�����󥸥�ˤȤä����̤ʰ�̣������ʤ� ʸ���Ȥ��ƹͤ���졢�֤��Τޤޡפǥޥå��󥰤��뤳�Ȥ����դ��Ƥ��������� =begin original To summarize, the C<\o{}> form is always safe to use, and the other form is safe to use for code points through \077 when you use exactly three digits to specify them. =end original �ޤȤ��ȡ�C<\o{}> �����Ͼ�˰����ǡ��⤦��Ĥη����ϡ����ꤹ��Ȥ��� ���Τ� 3 ���Ȥ���� \077 �ޤǤ������֤ʤ�����Ǥ��� =begin original Mnemonic: I<0>ctal or Ictal. =end original ����ˡ: 8 �ʿ�(I<0>ctal �ޤ��� Ictal)�� =head4 Examples (assuming an ASCII platform) (��(ASCII �ץ�åȥե��������)) $str = "Perl"; $str =~ /\o{120}/; # Match, "\120" is "P". $str =~ /\120/; # Same. $str =~ /\o{120}+/; # Match, "\120" is "P", it's repeated at least once $str =~ /\120+/; # Same. $str =~ /P\053/; # No match, "\053" is "+" and taken literally. /\o{23073}/ # Black foreground, white background smiling face. /\o{4801234567}/ # Raises a warning, and yields chr(4) =head4 Disambiguation rules between old-style octal escapes and backreferences (�Ť������� 8 �ʥ��������פȸ������ȤȤ�ۣ�椵��ʤ�����§) =begin original Octal escapes of the C<\000> form outside of bracketed character classes potentially clash with old-style backreferences. (see L below). They both consist of a backslash followed by numbers. So Perl has to use heuristics to determine whether it is a backreference or an octal escape. Perl uses the following rules to disambiguate: =end original �礫�ä�ʸ�����饹�γ�¦�Ǥ� C<\000> �����Ǥ� 8 �ʥ��������פ�����Ū�� �Ť������θ������Ȥ��˲����ޤ��� (��Ҥ� L ����)�� �����Ϥɤ����ե���å���˰���³�����ͤǹ�������ޤ��� ����� Perl �ϸ������Ȥ� 8 �ʥ��������פ�����ꤹ��Τ�ȯ��Ū��ˡ�� �Ȥ��ޤ��� Perl ��ۣ�椵��ʤ�������˰ʲ��ε�§��Ȥ��ޤ�: =over 4 =item 1 =begin original If the backslash is followed by a single digit, it's a backreference. =end original �ե���å���˰���³���Τ�ñ��ο����ʤ顢����ϸ������ȤǤ��� =item 2 =begin original If the first digit following the backslash is a 0, it's an octal escape. =end original �ե���å���˰���³��ʸ���� 0 �ʤ顢����� 8 �ʥ��������פǤ��� =item 3 =begin original If the number following the backslash is N (in decimal), and Perl already has seen N capture groups, Perl considers this a backreference. Otherwise, it considers it an octal escape. If N has more than three digits, Perl takes only the first three for the octal escape; the rest are matched as is. =end original �ե���å���˰���³�����ͤ� N (10 ��) �ǡ�Perl �����Ǥ� N �Ĥ� ��ª���롼�פ򸫤Ƥ���ʤ顢Perl �Ϥ����������ȤȤ��ư����ޤ��� ����ʤ���С������ 8 �ʥ��������פȤ��ư����ޤ��� N �� 3 ����Ĺ���ʤ顢Perl �� 8 �ʥ��������פȤ��ƺǽ�� 3 ��Τߤ� �Ȥ��ޤ�; �Ĥ�Ϥ��Τޤޥޥå��󥰤���ޤ��� my $pat = "(" x 999; $pat .= "a"; $pat .= ")" x 999; /^($pat)\1000$/; # Matches 'aa'; there are 1000 capture groups. /^$pat\1000$/; # Matches 'a@0'; there are 999 capture groups # and \1000 is seen as \100 (a '@') and a '0' =back =begin original You can force a backreference interpretation always by using the C<\g{...}> form. You can the force an octal interpretation always by using the C<\o{...}> form, or for numbers up through \077 (= 63 decimal), by using three digits, beginning with a "0". =end original ��� C<\g{...}> ������Ȥ����ȤǸ������Ȥ˲�᤹��褦�˶����Ǥ��ޤ��� ��� C<\o{...}> ������Ȥ�����\077 (= 10 �ʤ� 63) �ޤǤο��ͤξ��ϡ� "0" ����Ƭ���դ��ƾ�� 3 ��ǻȤ����Ȥ� 8 �ʿ��˲�᤹��褦�˶����Ǥ��ޤ��� =head3 Hexadecimal escapes (16 �ʿ�����������) =begin original Like octal escapes, there are two forms of hexadecimal escapes, but both start with the same thing, C<\x>. This is followed by either exactly two hexadecimal digits forming a number, or a hexadecimal number of arbitrary length surrounded by curly braces. The hexadecimal number is the code point of the character you want to express. =end original 8 �ʥ��������פ�Ʊ�͡�16 �ʥ��������פˤ���Ĥη���������ޤ������ɤ���� Ʊ�� C<\x> �ǻϤޤ�ޤ��� ��������Τ� 2 ��ο��ͤ�������� 16 �ʿ������뤤���椫�ä��ǰϤޤ줿 Ǥ�դη�� 16 �ʿ�������³���ޤ��� 16 �ʿ���ɽ��������ʸ���������֤Ǥ��� =begin original Note that a character expressed as one of these escapes is considered a character without special meaning by the regex engine, and will match "as is". =end original �����Υ��������פΰ�ĤǤ�ɽ�������ʸ��������ɽ�����󥸥�ˤȤä����̤� ��̣������ʤ�ʸ���Ȥ��ƹͤ���졢�֤��Τޤޡפǥޥå��󥰤��뤳�Ȥ� ���դ��Ƥ��������� =begin original Mnemonic: heIadecimal. =end original ����ˡ: 16 �ʿ�(heIadecimal)�� =head4 Examples (assuming an ASCII platform) (��(ASCII �ץ�åȥե��������)) $str = "Perl"; $str =~ /\x50/; # Match, "\x50" is "P". $str =~ /\x50+/; # Match, "\x50" is "P", it is repeated at least once $str =~ /P\x2B/; # No match, "\x2B" is "+" and taken literally. /\x{2603}\x{2602}/ # Snowman with an umbrella. # The Unicode character 2603 is a snowman, # the Unicode character 2602 is an umbrella. /\x{263B}/ # Black smiling face. /\x{263b}/ # Same, the hex digits A - F are case insensitive. =head2 Modifiers (������) =begin original A number of backslash sequences have to do with changing the character, or characters following them. C<\l> will lowercase the character following it, while C<\u> will uppercase (or, more accurately, titlecase) the character following it. They provide functionality similar to the functions C and C. =end original ¿���εե���å��奷�����󥹤ϡ�����³��ʸ�����ѹ����ޤ��� C<\l> �ϰ���³��ʸ����ʸ�����Ѥ��ޤ�; ����C<\u> �ϰ���³��ʸ������ʸ��(��� ���Τˤϥ����ȥ�ʸ��)�ˤ��ޤ��� ����ϴؿ� C ����� C �Ȼ����褦�ʵ�ǽ���󶡤��ޤ��� =begin original To uppercase or lowercase several characters, one might want to use C<\L> or C<\U>, which will lowercase/uppercase all characters following them, until either the end of the pattern or the next occurrence of C<\E>, whichever comes first. They provide functionality similar to what the functions C and C provide. =end original ʣ����ʸ������ʸ���ޤ��Ͼ�ʸ���ˤ���Τˡ�C<\L> �ޤ��� C<\U> �� �Ȥ��������⤷��ޤ���; ����ϡ��ѥ�����������ޤ��ϼ��� C<\E> �������ޤǤ����Ƥ�ʸ����ʸ��/��ʸ���ˤ��ޤ��� �����ϴؿ� C ����� C ��Ʊ���褦�ʵ�ǽ���󶡤��ޤ��� =begin original C<\Q> is used to quote (disable) pattern metacharacters, up to the next C<\E> or the end of the pattern. C<\Q> adds a backslash to any character that could have special meaning to Perl. In the ASCII range, it quotes every character that isn't a letter, digit, or underscore. See L for details on what gets quoted for non-ASCII code points. Using this ensures that any character between C<\Q> and C<\E> will be matched literally, not interpreted as a metacharacter by the regex engine. =end original C<\Q> �ϰ���³��ʸ����򡢼��� C<\E> �ޤ��ϥѥ�����κǸ�ޤ� ��������(̵����)���ޤ��� C<\Q> �� Perl ���ü�ʰ�̣��������Ƥ�ʸ���˵ե���å�����ɲä��ޤ��� ASCII ���ϰϤǤϡ��ѻ��������������Ǥʤ���Τ򥯥����Ȥ��ޤ��� �� ASCII �����֤Dz����������Ȥ���뤫�˴ؤ���ܺ٤ˤĤ��Ƥ� L �򻲾Ȥ��Ƥ��������� ����ˤ�� C<\Q> �� C<\E> �δ֤����Ƥ�ʸ���ϥ�ƥ��˥ޥå��󥰤��� ����ɽ�����󥸥�ˤ�äƥ᥿ʸ���Ȥ��Ʋ�ᤵ��ޤ��� =begin original C<\F> can be used to casefold all characters following, up to the next C<\E> or the end of the pattern. It provides the functionality similar to the C function. =end original C<\F> �ϼ��� C<\E> �ޤ��ϥѥ�����κǸ�ޤǾ��߹���ʸ���ˤ��ޤ��� ����� C �ؿ��Ȼ����褦�ʵ�ǽ���󶡤��ޤ��� =begin original Mnemonic: Iowercase, Ippercase, Iold-case, Iuotemeta, Ind. =end original ����ˡ: ��ʸ��(Iowercase)����ʸ��(Ippercase)�����߹���ʸ�� (Iold-case)����������(Iuotemeta)����λ(Ind)�� =head4 Examples (��) $sid = "sid"; $greg = "GrEg"; $miranda = "(Miranda)"; $str =~ /\u$sid/; # Matches 'Sid' $str =~ /\L$greg/; # Matches 'greg' $str =~ /\Q$miranda\E/; # Matches '(Miranda)', as if the pattern # had been written as /\(Miranda\)/ =head2 Character classes (ʸ�����饹) =begin original Perl regular expressions have a large range of character classes. Some of the character classes are written as a backslash sequence. We will briefly discuss those here; full details of character classes can be found in L. =end original Perl ������ɽ���Ϲ����ϰϤ�ʸ�����饹����äƤ��ޤ��� ʸ�����饹�ΰ����ϵե���å��奷�����󥹤Ȥ��ƽ񤫤�ޤ��� �����ǤϤ����ˤĤ��ƴʷ�˵������ޤ�; ʸ�����饹�˴ؤ��봰���ʾܺ٤� L �ˤ���ޤ��� =begin original C<\w> is a character class that matches any single I character (letters, digits, Unicode marks, and connector punctuation (like the underscore)). C<\d> is a character class that matches any decimal digit, while the character class C<\s> matches any whitespace character. New in perl 5.10.0 are the classes C<\h> and C<\v> which match horizontal and vertical whitespace characters. =end original C<\w> ��ñ���Ǥ�դ� I<ñ��> ʸ�� (�ѻ���������Unicode �ޡ����� (�����Τ褦��)��³������) �˥ޥå��󥰤���ʸ�����饹�Ǥ��� C<\d> �� 10 �ʿ����˥ޥå��󥰤���ʸ�����饹�Ǥ�; ����ʸ�����饹 C<\s> �� ����ʸ���˥ޥå��󥰤��ޤ��� perl 5.10.0 ����Ƴ�����줿�Τϡ����줾���ʿ����ʸ���ȿ�ľ����ʸ���� �ޥå��󥰤��� C<\h> �� C<\v> �Ǥ��� =begin original The exact set of characters matched by C<\d>, C<\s>, and C<\w> varies depending on various pragma and regular expression modifiers. It is possible to restrict the match to the ASCII range by using the C regular expression modifier. See L. =end original C<\d>, C<\s>, C<\w> �ǥޥå��󥰤���ʸ�������Τʽ�����͡��ʥץ饰�ޤ� ����ɽ�������Ҥ˰�¸���ưۤʤ�ޤ��� C ����ɽ�������Ҥ�Ȥ����Ȥ� ASCII ���ϰϤ˥ޥå��󥰤���褦�� ���¤Ǥ��ޤ��� L �򻲾Ȥ��Ƥ��������� =begin original The uppercase variants (C<\W>, C<\D>, C<\S>, C<\H>, and C<\V>) are character classes that match, respectively, any character that isn't a word character, digit, whitespace, horizontal whitespace, or vertical whitespace. =end original ��ʸ�����Ѽ� (C<\W>, C<\D>, C<\S>, C<\H>, C<\V>) �Ϥ��줾��ñ��ʸ���������� ���򡢿�ʿ���򡢿�ľ����ǤϤʤ�Ǥ�դ�ʸ���˥ޥå��󥰤��ޤ��� =begin original Mnemonics: Iord, Iigit, Ipace, Iorizontal, Iertical. =end original ����ˡ: ñ��(Iord)������(Iigit)������(Ipace)����ʿ(Iorizontal)�� ��ľ(Iertical)�� =head3 Unicode classes (Unicode ���饹) =begin original C<\pP> (where C

is a single letter) and C<\p{Property}> are used to match a character that matches the given Unicode property; properties include things like "letter", or "thai character". Capitalizing the sequence to C<\PP> and C<\P{Property}> make the sequence match a character that doesn't match the given Unicode property. For more details, see L and L. =end original C<\pP> (������ C

��ñ���ʸ��) �� C<\p{Property}> ��Ϳ����줿 Unicode �����˥ޥå��󥰤���ʸ���˥ޥå��󥰤��Ƥ��ޤ���; �����ˤ� "letter" �� "thai character" �Τ褦�ʤ�Τ��ޤޤ�ޤ��� �¤Ӥ� C<\PP> �� C<\P{Property}> �Τ褦�˥���ԥ��饤������ȡ�Ϳ����줿 Unicode �����˥ޥå��󥰤��ʤ�ʸ���˥ޥå��󥰤���褦�ˤʤ�ޤ��� ����ʤ�ܺ٤ˤĤ��Ƥϡ�L �� L �򻲾Ȥ��Ƥ��������� =begin original Mnemonic: I

roperty. =end original ����ˡ: ����(I

roperty)�� =head2 Referencing (����) =begin original If capturing parenthesis are used in a regular expression, we can refer to the part of the source string that was matched, and match exactly the same thing. There are three ways of referring to such I: absolutely, relatively, and by name. =end original ����ɽ������ª���ä����Ȥ���ȡ��ޥå��󥰤���������ʸ����ΰ����� ���Ȥ����ꡢ����Ʊ����Τ˥ޥå��󥰤�����Ǥ��ޤ��� ���Τ褦�� I<��������> �򻲾Ȥ���ˤϻ��Ĥ���ˡ������ޤ�: ���С����С� ̾���դ��Ǥ��� =for later add link to perlrecapture =head3 Absolute referencing (���л���) =begin original Either C<\gI> (starting in Perl 5.10.0), or C<\I> (old-style) where I is a positive (unsigned) decimal number of any length is an absolute reference to a capturing group. =end original (Perl 5.10.0 ��Ƴ�����줿) C<\gI> �ޤ��� (�Ť�������) C<\I> �� I �� Ǥ�դ�Ĺ��������(���ʤ�)10 �ʿ��ξ�硢��ª���롼�פؤ����л��ȤǤ��� =begin original I refers to the Nth set of parentheses, so C<\gI> refers to whatever has been matched by that set of parentheses. Thus C<\g1> refers to the first capture group in the regex. =end original I �Ϥ��ä��� N ���ܤν���򻲾Ȥ���Τǡ�C<\gI> �Ϥ��ä��Τ��ν���� �ޥå��󥰤����Τ򻲾Ȥ��ޤ��� ���äơ�C<\g1> ������ɽ����κǽ����ª���롼�פ򻲾Ȥ��Ƥޤ��� =begin original The C<\gI> form can be equivalently written as C<\g{I}> which avoids ambiguity when building a regex by concatenating shorter strings. Otherwise if you had a regex C, and C<$a> contained C<"\g1">, and C<$b> contained C<"37">, you would get C which is probably not what you intended. =end original C<\gI> �����ϡ����û��ʸ������礹�뤳�Ȥˤ������ɽ�����ۤ���Ȥ��� ۣ�椵���򤱤뤿��� C<\g{I}> �������˽񤱤ޤ��� ����ʤ���С�C �Ȥ�������ɽ�������äơ�C<$a> �� C<"\g1"> �����ꡢ C<$b> �� C<"37"> �����äƤ���ȡ�C �����뤳�Ȥˤʤꡢ�����餯 ˾��Ǥ��ʤ���ΤǤ��礦�� =begin original In the C<\I> form, I must not begin with a "0", and there must be at least I capturing groups, or else I is considered an octal escape (but something like C<\18> is the same as C<\0018>; that is, the octal escape C<"\001"> followed by a literal digit C<"8">). =end original C<\I> �����ǡ�I �� "0" �ǻϤޤäƤϤʤ餺�����ʤ��Ȥ� I �Ĥ� ��ª���롼�פ��ʤ���Фʤ�ޤ���; ����ʤ���� I �� 8 �ʥ��������פ� �ͤ����ޤ� (������ C<\18> �Τ褦�ʤ�Τ� C<\0018> ��Ʊ���Ǥ�; �Ĥޤꡢ 8 �ʥ��������� C<"\001"> �˰���³���ƥ�ƥ��ο��� C<"8"> �Ǥ�)�� =begin original Mnemonic: Iroup. =end original ����ˡ: ���롼��(Iroup)�� =head4 Examples (��) /(\w+) \g1/; # Finds a duplicated word, (e.g. "cat cat"). /(\w+) \1/; # Same thing; written old-style /(.)(.)\g2\g1/; # Match a four letter palindrome (e.g. "ABBA"). =head3 Relative referencing (���л���) =begin original C<\g-I> (starting in Perl 5.10.0) is used for relative addressing. (It can be written as C<\g{-I>.) It refers to the Ith group before the C<\g{-I}>. =end original (Perl 5.10.0 ��Ƴ�����줿) C<\g-I> �����л��ȤΤ���˻Ȥ��ޤ��� (����� C<\g{-I> �Ƚ񤱤ޤ���) C<\g{-N}> �� N �����Υ��롼�פ򻲾Ȥ��ޤ��� =begin original The big advantage of this form is that it makes it much easier to write patterns with references that can be interpolated in larger patterns, even if the larger pattern also contains capture groups. =end original ���η������礭�������ϡ���ª���롼�פ�ޤ�Ǥ���褦���礭�ʥѥ������ Ÿ�������褦�ʻ��ȤΥѥ���������ñ�˽񤱤뤳�ȤǤ��� =head4 Examples (��) /(A) # Group 1 ( # Group 2 (B) # Group 3 \g{-1} # Refers to group 3 (B) \g{-3} # Refers to group 1 (A) ) /x; # Matches "ABBA". my $qr = qr /(.)(.)\g{-2}\g{-1}/; # Matches 'abab', 'cdcd', etc. /$qr$qr/ # Matches 'ababcdcd'. =head3 Named referencing (̾���դ�����) =begin original C<\g{I}> (starting in Perl 5.10.0) can be used to back refer to a named capture group, dispensing completely with having to think about capture buffer positions. =end original (Perl 5.10.0 ��Ƴ�����줿) C<\g{I}> ��̾���դ���ª���롼�פؤ� �������Ȥ˻Ȥ�졢��ª�Хåե��ΰ��֤ˤĤ��ƹͤ���ɬ�פ����ˤʤ����ޤ��� =begin original To be compatible with .Net regular expressions, C<\g{name}> may also be written as C<\k{name}>, C<< \k >> or C<\k'name'>. =end original .Net ����ɽ���Ȥθߴ����Τ���ˡ�C<\g{name}> �� C<\k{name}>, C<< \k >>, C<\k'name'> �Ȥ�񤱤ޤ��� =begin original To prevent any ambiguity, I must not start with a digit nor contain a hyphen. =end original ۣ�椵���򤱤뤿��ˡ�I �Ͽ��ͤǻϤޤä���ϥ��ե��ޤ���ꤷ�Ƥ� �����ޤ��� =head4 Examples (��) /(?\w+) \g{word}/ # Finds duplicated word, (e.g. "cat cat") /(?\w+) \k{word}/ # Same. /(?\w+) \k/ # Same. /(?.)(?.)\g{letter2}\g{letter1}/ # Match a four letter palindrome (e.g. "ABBA") =head2 Assertions (ɽ��) =begin original Assertions are conditions that have to be true; they don't actually match parts of the substring. There are six assertions that are written as backslash sequences. =end original ɽ���Ͽ��Ǥ���ɬ�פ�������Ǥ�; �ºݤ���ʬʸ����ΰ����� �ޥå��󥰤��뤳�ȤϤ���ޤ��� �ե���å��奷�����󥹤Ȥ��ƽ񤫤��ϻ�Ĥ�ɽ��������ޤ��� =over 4 =item \A =begin original C<\A> only matches at the beginning of the string. If the C modifier isn't used, then C is equivalent to C. However, if the C modifier is used, then C matches internal newlines, but the meaning of C isn't changed by the C modifier. C<\A> matches at the beginning of the string regardless whether the C modifier is used. =end original C<\A> ��ʸ�������Ƭ�ˤΤߥޥå��󥰤��ޤ��� C �����Ҥ��Ȥ��Ƥ��ʤ���С�C �� C �������Ǥ��� ��������C �����Ҥ��Ȥ���ȡ�C ���������Ԥ˥ޥå��󥰤��ޤ����� C �ΰ�̣�� C �����Ҥˤ�ä��Ѥ��ޤ��� C<\A> �ϡ�C �����Ҥ��Ȥ��뤫�ɤ����˴ؤ�餺ʸ�������Ƭ�� �ޥå��󥰤��ޤ��� =item \z, \Z =begin original C<\z> and C<\Z> match at the end of the string. If the C modifier isn't used, then C is equivalent to C; that is, it matches at the end of the string, or one before the newline at the end of the string. If the C modifier is used, then C matches at internal newlines, but the meaning of C isn't changed by the C modifier. C<\Z> matches at the end of the string (or just before a trailing newline) regardless whether the C modifier is used. =end original C<\z> �� C<\Z> ��ʸ����������˥ޥå��󥰤��ޤ��� C �����Ҥ��Ȥ��Ƥ��ʤ���С�C �� C �������Ǥ�; ʸ����� ��������ʸ����������β��Ԥμ����˥ޥå��󥰤��ޤ��� C �����Ҥ��Ȥ���ȡ�C ���������Ԥ˥ޥå��󥰤��ޤ����� C �ΰ�̣�� C �����Ҥˤ�ä��Ѥ��ޤ��� C<\Z> �ϡ�C �����Ҥ��Ȥ��뤫�ɤ����˴ؤ�餺ʸ���������(���뤤�� �����β��Ԥ�ľ��)�˥ޥå��󥰤��ޤ��� =begin original C<\z> is just like C<\Z>, except that it does not match before a trailing newline. C<\z> matches at the end of the string only, regardless of the modifiers used, and not just before a newline. It is how to anchor the match to the true end of the string under all conditions. =end original C<\z> �� C<\Z> ��Ʊ�ͤǤ����������β��Ԥμ����Ǥϥޥå��󥰤��ޤ��� C<\z> ��ʸ����������ˤΤߥޥå��󥰤��ޤ� - �����Ҥ��Ȥ��뤫����Ԥ� �����˴ؤ��ޤ��� ����ϥ��󥫡�����������δ��ʸ����ο��������˥ޥå��󥰤�����ˡ�Ǥ��� =item \G =begin original C<\G> is usually used only in combination with the C modifier. If the C modifier is used and the match is done in scalar context, Perl remembers where in the source string the last match ended, and the next time, it will start the match from where it ended the previous time. =end original C<\G> �����̤� C �����ҤȤ��Ȥ߹�碌�ǤΤ߻Ȥ��ޤ��� C �����Ҥ��Ȥ�졢�ޥå��󥰤������饳��ƥ����ȤǹԤ���ȡ� Perl �ϺǸ�Υޥå��󥰤���λ����������ʸ����ΰ��֤�Ф��Ƥ��ơ������ �ޥå��󥰤Ǥϡ����󽪤�ä����֤���ޥå��󥰤򳫻Ϥ��ޤ��� =begin original C<\G> matches the point where the previous match on that string ended, or the beginning of that string if there was no previous match. =end original C<\G> �Ϥ���ʸ���������Υޥå��󥰤���λ�������֡����뤤������� �ޥå��󥰤��ʤ����ʸ�������Ƭ�˥ޥå��󥰤��ޤ��� =for later add link to perlremodifiers =begin original Mnemonic: Ilobal. =end original ����ˡ: �������Х�(Ilobal)�� =item \b, \B =begin original C<\b> matches at any place between a word and a non-word character; C<\B> matches at any place between characters where C<\b> doesn't match. C<\b> and C<\B> assume there's a non-word character before the beginning and after the end of the source string; so C<\b> will match at the beginning (or end) of the source string if the source string begins (or ends) with a word character. Otherwise, C<\B> will match. =end original C<\b> ��ñ��ʸ������ñ��ʸ���ζ����˥ޥå��󥰤��ޤ�; C<\B> �� C<\b> �� �ޥå��󥰤��ʤ�Ǥ�դ�ʸ���֤˥ޥå��󥰤��ޤ��� C<\b> �� C<\B> �ϡ�������ʸ�������Ƭ�����������θ������ñ��ʸ��������� ���ꤷ�ޤ�; ���ä� C<\b> �ϡ�������ʸ����ñ��ʸ���ǻϤޤäƤ���(�ޤ��� ����äƤ���)���ϥ�����ʸ�������Ƭ(�ޤ�������)�˥ޥå��󥰤��ޤ��� ����ʤ���С�C<\B> ���ޥå��󥰤��ޤ��� =begin original Do not use something like C<\b=head\d\b> and expect it to match the beginning of a line. It can't, because for there to be a boundary before the non-word "=", there must be a word character immediately previous. All boundary determinations look for word characters alone, not for non-words characters nor for string ends. It may help to understand how <\b> and <\B> work by equating them as follows: =end original C<\b=head\d\b> �Τ褦�ʤ�Τ�Ȥäƹ�Ƭ�˥ޥå��󥰤���� ���ꤷ�ʤ��Ǥ��������� ����ϤǤ��ޤ���; �ʤ��ʤ���ñ�� "=" �����˶��������ꡢľ����ñ��ʸ���� �ʤ���Фʤ�ʤ�����Ǥ��� ���Ƥζ��������ñ��ʸ���Τߤ�õ������ñ��ʸ����ʸ�����������õ���ޤ��� <\b> �� <\B> ���ɤΤ褦��ư��뤫�ϰʲ��Τ褦��Ʊ�������뤳�Ȥ� ����ν����ˤʤ�Ǥ��礦: \b really means (?:(?<=\w)(?!\w)|(?oundary. =end original ����ˡ: ����(Ioundary)�� =back =head4 Examples (��) "cat" =~ /\Acat/; # Match. "cat" =~ /cat\Z/; # Match. "cat\n" =~ /cat\Z/; # Match. "cat\n" =~ /cat\z/; # No match. "cat" =~ /\bcat\b/; # Matches. "cats" =~ /\bcat\b/; # No match. "cat" =~ /\bcat\B/; # No match. "cats" =~ /\bcat\B/; # Match. while ("cat dog" =~ /(\w+)/g) { print $1; # Prints 'catdog' } while ("cat dog" =~ /\G(\w+)/g) { print $1; # Prints 'cat' } =head2 Misc (����¾) =begin original Here we document the backslash sequences that don't fall in one of the categories above. These are: =end original �����ǤϾ�ҤΥ��ƥ���ΰ�Ĥ����ƤϤޤ�ʤ��ե���å��奷�����󥹤ˤĤ��� ���Ҥ��ޤ��� �����: =over 4 =item \C =begin original C<\C> always matches a single octet, even if the source string is encoded in UTF-8 format, and the character to be matched is a multi-octet character. C<\C> was introduced in perl 5.6. This is very dangerous, because it violates the logical character abstraction and can cause UTF-8 sequences to become malformed. =end original C<\C> �ϡ��㤨������ʸ���� UTF-8 �����ǥ��󥳡��ɤ���Ƥ��Ƥ⡢ ���ñ��Υ����ƥåȤ˥ޥå��󥰤����ޥå��󥰤���ʸ����ʣ�������ƥå� ʸ���Ǥ��� C<\C> �� perl 5.6 ��Ƴ������ޤ����� ����ϤȤƤ�����Ǥ�; �ʤ��ʤ餳�������ʸ����ݲ��˰�ȿ����UTF-8 �¤Ӥ� �����ʤ�Τˤ����ǽ�������뤫��Ǥ��� =begin original Mnemonic: oItet. =end original ����ˡ: �����ƥå�(oItet)�� =item \K =begin original This appeared in perl 5.10.0. Anything matched left of C<\K> is not included in C<$&>, and will not be replaced if the pattern is used in a substitution. This lets you write C instead of C or C. =end original ����� perl 5.10.0 ���鸽��ޤ����� C<\K> �κ�¦�ǥޥå��󥰤�����Τ� C<$&> �˴ޤޤ�ޤ��� �ѥ������ִ��ǻȤ�줿�����֤��������ޤ��� ����ˤ�ꡢC or C �� ����� C �Ƚ񤱤ޤ��� =begin original Mnemonic: Ieep. =end original Mnemonic: �ݻ�(Ieep)�� =item \N =begin original This is an experimental feature new to perl 5.12.0. It matches any character that is B a newline. It is a short-hand for writing C<[^\n]>, and is identical to the C<.> metasymbol, except under the C flag, which changes the meaning of C<.>, but not C<\N>. =end original ����� perl 5.12.0 ����μ¸�Ū�ʵ�ǽ�Ǥ��� ����ϲ��� B<�Ǥʤ�> Ǥ�դ�ʸ���˥ޥå��󥰤��ޤ��� ����� C<[^\n]> �ξ�ά���ǡ�C<.> �᥿ʸ����Ʊ���Ǥ�����C<.> �ΰ�̣���Ѥ��� C �ե饰���դ��Ƥ��Ƥ� C<\N> �ΰ�̣���Ѥ��ޤ��� =begin original Note that C<\N{...}> can mean a L. =end original C<\N{...}> �� L<̾���ޤ����ֹ��ʸ�� |/Named or numbered characters and character sequences> �� ��̣���뤫���Τ�ʤ����Ȥ����դ��Ƥ��������� =begin original Mnemonic: Complement of I<\n>. =end original ����ˡ: I<\n> ������� =item \R X<\R> =begin original C<\R> matches a I; that is, anything considered a linebreak sequence by Unicode. This includes all characters matched by C<\v> (vertical whitespace), and the multi character sequence C<"\x0D\x0A"> (carriage return followed by a line feed, sometimes called the network newline; it's the end of line sequence used in Microsoft text files opened in binary mode). C<\R> is equivalent to C<< (?>\x0D\x0A|\v) >>. (The reason it doesn't backtrack is that the sequence is considered inseparable. That means that =end original C<\R> �� I<����Ū�ʲ���> �˥ޥå��󥰤��ޤ�; ����� Unicode �Dz����¤ӤȤ��� �������ΤǤ��� ����ˤ� C<\v> (��ľ����) �ǥޥå��󥰤������Ƥ�ʸ����ʣ��ʸ���¤� C<"\x0D\x0A"> (�����˰���³���Ʋ��ԡ������ͥåȥ�����ԤȸƤФ����; ����� Microsoft �ƥ����ȥե������Х��ʥ�⡼�ɤdz��������˻Ȥ��� �����¤ӤǤ�) ��ޤߤޤ��� C<\R> �� C<< (?>\x0D\x0A)|\v) >> �������Ǥ��� (�Хå��ȥ�å����ʤ���ͳ�ϡ��¤Ӥ�ʬ��Ǥ��ʤ��ȹͤ����뤫��Ǥ��� �Ĥޤꡢ "\x0D\x0A" =~ /^\R\x0A$/ # No match =begin original fails, because the C<\R> matches the entire string, and won't backtrack to match just the C<"\x0D">.) Since C<\R> can match a sequence of more than one character, it cannot be put inside a bracketed character class; C is an error; use C<\v> instead. C<\R> was introduced in perl 5.10.0. =end original �ϼ��Ԥ��ޤ�; C<\R> ��ʸ�������Τ˥ޥå��󥰤���C<"\x0D"> ������ �ޥå��󥰤���褦�˥Хå��ȥ�å����ʤ�����Ǥ���) C<\R> ��ʣ����ʸ�����¤Ӥ˥ޥå��󥰤���Τǡ��礫�ä�ʸ�����饹����¦�ˤ� �Ȥ��ޤ���; C �ϥ��顼�Ǥ�; ����� C<\v> ��ȤäƤ��������� C<\R> �� perl 5.10.0 ��Ƴ������ޤ����� =begin original Note that this does not respect any locale that might be in effect; it matches according to the platform's native character set. =end original �����ͭ�����⤷��ʤ����������ǧ�����ʤ����Ȥ����դ��Ƥ�������; ����� �ץ�åȥե�����Υͥ��ƥ��֤�ʸ������˽��äƥޥå��󥰤��ޤ��� =begin original Mnemonic: none really. C<\R> was picked because PCRE already uses C<\R>, and more importantly because Unicode recommends such a regular expression metacharacter, and suggests C<\R> as its notation. =end original ����ˡ: �ºݤΤȤ�������ޤ��� C<\R> �����Ф줿�Τϡ�PCRE ������ C<\R> ��ȤäƤ��ơ�����˽��פʤΤ� Unicode �����Τ褦������ɽ���᥿ʸ���򴫤�Ƥ��ơ���ˡ�Ȥ��� C<\R> �� ��Ƥ��Ƥ��뤫��Ǥ��� =item \X X<\X> =begin original This matches a Unicode I. =end original ����� Unicode �� I<��ĥ���ǥ��饹��> (extended grapheme cluster) �� �ޥå��󥰤��ޤ��� =begin original C<\X> matches quite well what normal (non-Unicode-programmer) usage would consider a single character. As an example, consider a G with some sort of diacritic mark, such as an arrow. There is no such single character in Unicode, but one can be composed by using a G followed by a Unicode "COMBINING UPWARDS ARROW BELOW", and would be displayed by Unicode-aware software as if it were a single character. =end original C<\X> �����̤� (�� Unicode �ץ�����ޤ�) �Ȥ�����ñ���ʸ���ȹͤ������Τ� ���ʤꤦ�ޤ��ޥå��󥰤��ޤ��� �㤨�С�����Τ褦�ʡ����餫�Υ���������ƥ�����ޡ����դ��� G ��ͤ��ޤ��� Unicode �ˤϤ��Τ褦��ñ���ʸ���Ϥ���ޤ��󤬡�G �˰���³���� Unicode �� "COMBINING UPWARDS ARROW BELOW" ��Ȥ����Ȥǹ����Ǥ���Unicode ��ǧ������ ���եȥ������˰ͤä�ñ���ʸ���Ǥ��뤫�Τ褦��ɽ������ޤ��� =begin original Mnemonic: eItended Unicode character. =end original ����ˡ: ��ĥ Unicode ʸ��(eItended Unicode character)�� =back =head4 Examples (��) "\x{256}" =~ /^\C\C$/; # Match as chr (0x256) takes 2 octets in UTF-8. $str =~ s/foo\Kbar/baz/g; # Change any 'bar' following a 'foo' to 'baz' $str =~ s/(.)\K\g1//g; # Delete duplicated characters. "\n" =~ /^\R$/; # Match, \n is a generic newline. "\r" =~ /^\R$/; # Match, \r is a generic newline. "\r\n" =~ /^\R$/; # Match, \r\n is a generic newline. "P\x{307}" =~ /^\X$/ # \X matches a P with a dot above. =cut =begin meta Translate: SHIRAKATA Kentaro (5.10.1-) Status: completed =end meta