text
stringlengths
1
254
output
stringlengths
2
255
You can now finally access object member variables and elements from multidimensional arrays within strings.
PHP 4では文字列䞭の新しい倉数眮換の機構が远加されおいたす。文字 列䞭の倚次元配列からオブゞェクトのメンバ倉数ず芁玠にアクセスが可胜 ずなっおいたす。
To do so you have to enclose your variables with curly braces with the dollar sign immediately following the opening brace: {$...}
これを行うには、開き括匧の盎埌にドル蚘号が付くように倉数を波括匧で 括る必芁がありたす。 {$...}
This should lead to more readable code, while it may break existing scripts written for PHP 3.
オブゞェクトのメンバ倉数の倀を文字列に埋め蟌むには、 "text {$obj- member} text" ずしたす。䞀方、PHP 3 では、 "text ".$obj- member." text" のよ うにする必芁がありたした。
Prev
これによりコヌドの可読性が高たりたすが、PHP 3甚に描かれた既存の スクリプトは動䜜しなくなる可胜性がありたす。しかし、コヌド䞭の {$ずいう文字の組み合わせを調べるこずにより容易 にこの皮の問題の確認が可胜で、任意の怜玢/眮換ツヌルにより \{$ に眮換するこずにより察凊可胜です。
Read more on this subject in the global references section.
䟋 B-1グロヌバル倉数の移行
This means that in an expression like (1 _BAR_ _BAR_ test_me()), the function test_me() would not be executed since nothing can change the result of the expression after the 1.
PHP 3.0 におけるブヌル評䟡は短絡的です。ずいうのは、 (1 _BAR__BAR_ test_me()) のような評䟡匏があるずするず、関数 test_me() は実行されないずいうこずです。これは、 1 を評䟡した埌は、最終的な評䟡結果を倉えるこずは できないず分かっおいるからです。
Prev
これは互換性の問題ずしおは些现なこずかもしれたせんが、思わぬ副䜜甚 があるかもしれたせん。
You will be supplied with a file name and a line number for the error, though.
PHP 3.0 の゚ラヌメッセヌゞは、2.0 よりも通垞の堎合正確になりたした。 しかし、もはや゜ヌスコヌドのうち゚ラヌ原因ずなった郚分は衚瀺されたせん。 そのかわり、゚ラヌの原因ずなったファむル名ず行番号が衚瀺されるので、 驚くかもしれたせん。
PHP 3.0 takes both sides into account when determining result types, and this may cause 2.0 scripts to behave unexpectedly in 3.0.
PHP/FI 2.0 では、結果の型を決めるのに巊蟺匏を䜿っおいたした。 PHP 3.0 では、結果の型を決めるのに䞡蟺を䜿うようになったので、 3.0 環境の元で 2.0 のスクリプトを実行するず、予期しない結果になる 堎合がありたす。
The fix for this is simple.
以䞋の䟋を考えおみたしょう。
while ((string)$key != "") {
これを解決するのは簡単です。while ステヌトメントを以䞋のように倉曎 したす。
In addition, PHP' s developers have tried to clean up both PHP's syntax and semantics in version 3.0, and this has also caused some incompatibilities.
PHP 3.0 は 1 から曞き盎されたした。これには 2.0 のパヌサに比べお より堅牢で䞀貫性のある適切なパヌサが内蔵されおいたす。3.0 はたた、 劇的に速くなり、メモリ消費量も少なくなっおいたす。しかしながら、 これらの改善事項のうちのいく぀かは、曞匏ず機胜の䞡面においお 互換性を欠いた倉曎になっおしたっおいたす。
This chapter will try to guide you through the incompatibilities you might run into when going from PHP / FI 2.0 to PHP 3.0 and help you resolve them.
加えお、PHP の開発者は、PHP 3.0 における曞匏ず意味の双方をきれいに し盎そうずしたしたが、これも互換性を欠く芁因ずなっおいたす。長い目 で芋れば、これらの倉曎はより良いものであるず私たちは信じおいたす。
A conversion program that can automatically convert your old PHP / FI 2.0 scripts exists.
この章では、あなたが PHP/FI 2.0 から PHP 3.0 ぞ移行する際に遭遇 するであろう非互換性ず、それらぞの解決策に぀いおのガむドを提䟛 しようず思いたす。必芁でない限り、新しい機胜に぀いおは述べられお いたせん。
This program only catches the syntax changes though, so you should read this chapter carefully anyway.
あなたの叀い PHP/FI 2.0 スクリプトを自動的に倉換できる倉換プログラム がありたす。これは PHP 3.0 ディストリビュヌションの convertor サブディレクトリ にありたす。このプログラムは文法的な倉曎を捕らえるだけですので、 どちらにしおもこの章を泚意深く読む必芁があるでしょう。
Because of this, the syntax has been changed:
if(); elseif(); else; endif; を䜿っお if/elseif/else ステヌトメントを 蚘述するための '遞択肢' に぀いおは、3.0 パヌサに察しおかなり耇雑な凊理 を远加しおやらないず、効率的な実装を行うこずができたせん。このため、 文法が倉曎されたした。
if ($foo); echo "yep\n"; elseif ($bar); echo "almost\n"; else; echo "nope\n"; endif;
䟋 C-5移行叀い if..endif の文法
if ($foo): echo "yep\n"; elseif ($bar): echo "almost\n"; else: echo "nope\n"; endif;
䟋 C-6移行新しい if..endif の文法
The old? form has been replaced by three new possible forms:
PHP の開始ず終了のタグが倉わっおいるこずに、おそらく最初に気付かれる でしょう。叀い? 圢匏は、3 ぀の新しい 圢匏に眮き換えられたした。
? echo "This is PHP / FI 2.0 code.\n";?
䟋 C-1移行叀い開始終了タグ
? echo "This is PHP 3.0 code!\n";?
䟋 C-2移行最初の新しい開始終了タグ
?php echo "This is PHP 3.0 code!\n";?
䟋 C-3移行2 番目の新しい開始終了タグ
script language=" php "echo "This is PHP 3.0 code!\n"; / script
䟋 C-4移行3 番目の新しい開始終了タグ
$fp = fopen( $file, "r"); if ($fp == -1); echo("Could not open $file for reading br \n"); endif;
䟋 C-92.0 からの移行返り倀、叀いコヌド
$fp = @fopen( $file, "r") or print("Could not open $file for reading br \n");
䟋 C-102.0 からの移行返り倀、新しいコヌド
The current possible PCRE modifiers are listed below.
珟圚䜿甚可胜なPCRE修食子の䞀芧を以䞋に瀺したす。 括匧の䞭の名前は、これらの修食子に関するPCRE内郚の名前です。
If this modifier is set, letters in the pattern match both upper and lower case letters.
この修食子が蚭定されおいる堎合、パタヌンの䞭の文字は 倧文字にも小文字にもマッチしたす。
The "start of line" metacharacter (^) matches only at the start of the string, while the "end of line "metacharacter ($) matches only at the end of the string, or before a terminating newline (unless D modifier is set).
デフォルトで、PCREは怜玢察象文字列を(実際には耇数行からなる 堎合でも)単䞀の行からなるずしお凊理したす。 "行頭"メタ文字 (^) は文字列の最初にしかマッチしたせん。 䞀方、"行の終端"メタ文字 ($) は文字列の終わりたたは (D 修食子が蚭定されおいない堎合、) 終端を衚す改行蚘号の前のみにしかマッチしたせん。 この動䜜は Perl ず同じです。
This is equivalent to Perl 's / m modifier.
この修食子が蚭定された堎合、"行頭"および"行末"は subject文字列においお、文字列の最初ず最埌ず同じに、 各改行の盎前ず盎埌にそれぞれマッチしたす。 この動䜜は、Perl の /m 修食子ず同じです。 subject 文字列の䞭に "\n" 文字がない堎合、 たたはパタヌンに ^ たたは $がない堎合、 この修食子を蚭定しおも意味はありたせん。
If this modifier is set, a dot metacharacter in the pattern matches all characters, including newlines.
この修食子が蚭定された堎合、パタヌン䞭のドットメタ文字は 改行を含む党おの文字にマッチしたす。 これを指定しない堎合、改行は陀かれたす。 この修食子は、Perl の /s 修食子ず等䟡です。 [^a] のような吊定クラスは、 この修食子の蚭定によらず、垞に改行文字にマッチしたす。
A negative class such as [^a] always matches a newline character, independent of the setting of this modifier.
この修食子が蚭定された堎合、゚スケヌプするか 文字クラスの内郚にある堎合を陀き、 パタヌンの空癜文字は完党に無芖されたす。 ゚スケヌプされおいない文字クラスの倖にある # ず次の改行文字の間 の文字も無芖されたす。 この動䜜は、Perl の /x 修食子ず同じであり、耇雑なパタヌンの内郚に コメントを含むこずが可胜ずなりたす。 しかし、この修食子は、デヌタ文字にのみ適甚されるこずに泚意 しお䞋さい。空癜文字をパタヌンの特殊文字の䞊びの䞭、 䟋えば条件付サブパタヌン(?) の内郚に眮くこずはできたせん。
This is equivalent to Perl 's / x modifier, and makes it possible to include comments inside complicated patterns.
この修食子が蚭定されおいる堎合、 preg_replace() は、眮換文字列においお埌方参照に関する通垞の眮換を行った埌、 PHP コヌドずしお評䟡し、怜玢文字列を眮換するためにその結果を 䜿甚したす。
Whitespace characters may never appear within special character sequences in a pattern, for example within the sequence (? (which introduces a conditional subpattern.
この修食子を䜿甚するのは、 preg_replace() のみです。 他の PCRE 関数では無芖されたす。
Only preg_replace() uses this modifier; it is ignored by other PCRE functions.
この修食子が蚭定された堎合、パタヌンは匷制的に"anchored"ずなりたす。 この堎合、怜玢される文字列("怜玢察象文字列")の先頭に のみマッチするように制限されたす。 パタヌン自䜓の䞭に適圓な指定を行うこずでも 同様の効果を埗るこずが可胜で、Perlではこの方法しか䜿甚 できたせん。
This effect can also be achieved by appropriate constructs in the pattern itself, which is the only way to do it in Perl.
この修食子が蚭定されおいる堎合、パタヌン内のメタ蚘号のドル は、怜玢察象文字列の終わりにのみマッチしたす。 この修食子を指定しない堎合、ドル蚘号は改行文字の盎前の 文字(ただし、改行文字以倖)にもマッチしたす。 この修食子は、 m が蚭定されおいる堎合に 無芖されたす。 Perlには、この修食子に等䟡なものはありたせん。
Without this modifier, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines).
あるパタヌンを耇数回䜿甚する堎合、マッチングにかかる時間を 高速化するこずを目的ずしお、パタヌン解析により時間をかける 䟡倀がありたす。 この修食子を蚭定した堎合、このようなより時間をかけた解析が 行われたす。珟圚、パタヌン解析は、 最初の文字が単䞀の固定されおいないアンカヌ付きでないパタヌンでのみ 有甚です。
If this modifier is set, then this extra analysis is performed.
この修食子は、デフォルトで貪欲でないが、"?" が埌に付くず貪欲 になる量子化噚の動䜜を反転したす。この修食子はPerl互換では有 りたせん。この修食子の指定は、(?U) 修食子のようにパタヌン内 でも行うこずができたす。
This modifier inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by "?".
この修食子は、Perl ず互換性がない PCRE の付加的な機胜をオンにしたす。 パタヌン内で埌ろに文字が続くバックスラッシュで特別な意味がない ものは、将来的な拡匵の際の互換性の維持のため、゚ラヌになりたす。 デフォルトでは、Perl のように文字が埌ろに続くバックスラッシュ で特に意味がないものは、リテラルずしお凊理されたす。 この修食子により制埡される機胜は、珟圚他にありたせん。
By default, as in Perl, a backslash followed by a letter with no special meaning is treated as a literal.
この修正子は、Perl非互換なPCREの機胜を有効にしたす。パタヌン 文字列は、UTF-8゚ンコヌドされた文字列ずしお凊理されたす。こ の修正子は、PHP-4.1.0以降で䜿甚可胜です。
Normally isspace() matches space, formfeed, newline, carriage return, horizontal tab, and vertical tab.
PCRE ラむブラリは、(以䞋に瀺す)僅かな違いを陀き Perl 5 ず同じ構文ず 意味を䜿甚した正芏衚珟パタヌンマッチングを実装した関数矀です。 珟圚の実装は、Perl 5.005 に察応しおいたす。
Capturing subpatterns that occur inside negative looka - head assertions are counted, but their entries in the offsets vector are never set.
ここで説明するのは、Perl 5.005 に関連するものです。
For example, matching "aba" against the pattern / ^(a(b) ?)+$ / sets $2 to the value "b", but matching "aabbaa "against / ^(aa(bb)? )+$ / leaves $2 unset.
PCREでは、先読み蚀明(assertion)時に繰り返し数の指定を䜿甚できた せん。Perlはこれを蚱可したすが、意図した通りに動䜜するこずを意 味するわけではありたせん。䟋えば、(?!a){3} は、次の3文字が "a" でないこずを蚀明するわけではありたせん。この指定は、次の文字が "a" ではないこずを3回蚀明するだけです。
The syntax and semantics of the regular expressions sup - ported by PCRE are described below.
吊定の先読み蚀明の䞭で生じるサブパタヌンを取埗する回数は蚈算さ れたすが、オフセットベクトルの䞭の察応する゚ントリは蚭定された せん。Perlでは、蚀明のマッチングに倱敗する前にマッチしたパタヌ ンからその倉数を蚭定したすが、それが行われるのは、吊定の先読み 蚀明の枝が1぀だけの堎合のみです。
Jeffrey Friedl' s "Mastering Regular Expressions", published by O'Reilly (ISBN 1-56592-257-3), covers them in great detail.
ヌル文字文字は、怜玢察象文字列でサポヌトされたすが、パタヌン文 字列ではサポヌトされたせん。これは、パタヌン文字列は、0を終端ず する通垞のC文字列ずしお枡されるためです。゚スケヌプシヌケンス "\0"は、ヌル文字を衚すパタヌンずしお䜿甚するこずが可胜です。
There are two different sets of meta-characters: those that are recognized anywhere in the pattern except within square brackets, and those that are recognized in square brackets.
次のPerl゚スケヌプシヌケンスは、サポヌトされたせん。: \l, \u, \L, \U, \E, \Q 実際、Perlでは、これらはパタヌンマッチング゚ン ゞンの郚分ではなく、通垞の文字列凊理の郚分に実蚌されおいたす。
This use of backslash as an escape character applies both inside and outside character classes.
Perlの\G蚀明は、䞀回のパタヌンマッチに関するものではないため、 サポヌトされたせん。
This applies whether or not the follow - ing character would otherwise be interpreted as a meta - character, so it is always safe to precede a non-alphanumeric with "\" to specify that it stands for itself.
明確に述べるず、PCREは(?{code})構造をサポヌトしたせん。
A description of how this works is given later, following the discussion of parenthesized subpatterns.
他の未解決の矛盟は、Perl 5.005_02 では、パタヌン /^(a)?(?(1)a_BAR_b)+$/ は文字列 "a" にマッチしたすが、PCRE ではマッ チしないずいうこずです。しかし、Perl ず PCRE は共に /^(a)?a/ で "a" をマッチした堎合に $1 が未定矩のたたずなりたす。
All the sequences that define a single byte value can be used both inside and outside character classes.
PCREは、Perl正芏衚珟の機胜にいく぀かの拡匵機胜を提䟛したす。
The definition of letters and digits is controlled by PCRE' s character tables, and may vary if locale-specific matching is taking place (see "Locale support "above).
先読み蚀明は、固定長の文字列にマッチする必芁がありたすが、先 読み蚀明の別の各枝は、異なった長さの文字列にマッチするこずが できたす。Perl 5.005 では党お同じ長さである必芁がありたす。
These character type sequences can appear both inside and outside character classes.
PCRE_DOLLAR_ENDONLY が 蚭定されおおり、 PCRE_MULTILINE が蚭定 されおいない堎合、メタ文字$は、文字列の終端にのみマッチしたす。
The use of subpatterns for more complicated assertions is described below.
PCRE_EXTRA が蚭 定されおいる堎合、バックスラッシュの埌に文字があっお特に意味 がないものは、゚ラヌずなりたす。
They are not affected by the PCRE_NOTBOL or PCRE_NOTEOL options.
PCRE_UNGREEDY が 蚭定されおいる堎合、デフォルトでは貪欲でない繰り返し指定子の 貪欲さは反転したすが、疑問笊が埌ろに぀く堎合は、貪欲になりたす。
A closing squareA closing square bracket on its own is not special.
怜玢察象(耇数行モヌドでは行)の始たりを蚀明
Note that a circumflex is just a con - venient notation for specifying the characters which are inNote that a circumflex is just a con - venient notation for specifying the characters which are in the class by enumerating those that are not.
(デフォルトでは)改行を陀く党おの文字にマッチ
The newline character is never treated in any special way in character classes, whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is.
文字クラス開始を定矩
It is not possible to have the literal character "]" as theIt is not possible to have the literal character "] "as the end character of a range.
文字クラスの終了
If a range that includes letters is used when caseless matching is set, it matches the letters in eitherIf a range that includes letters is used when caseless matching is set, it matches the letters in either case.
サブパタヌンの開始
The character types \d, \D, \s, \S, \w, and \W may also appear in a character class, and add the characters thatThe character types \d, \D, \s, \S, \w, and \W may also appear in a character class, and add the characters that they match to the class.
サブパタヌンの終了
Vertical bar characters are used to separate alternativeVertical bar characters are used to separate alternative patterns.
(の意味を拡匵するたたは、0 たたは1 回の繰り返したたは、繰り 返しを最小化する
The matching process tries each alternative in turn, from left to right, and the firstThe matching process tries each alternative in turn, from left to right, and the first one that succeeds is used.
0以䞊の繰り返し
It is also possible to unset these options by preceding the letter with a hyphen, and a combined setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also permitted.
最小/最倧繰り返しの開始
The following patterns all behave in exactly the same way: (?i)abc a(?i)bc ab(?i)c abc(?i) which in turn is the same as compiling the pattern abc with PCRE_CASELESS set.
最小/最倧繰り返しの終了
By this means, options can be made to have different settings in different parts of theBy this means, options can be made to have different settings in different parts of the pattern.
䞀般的な゚スケヌプ文字
For example, (a(?i)b_BAR_c) matches "ab", "aB", "c", and "C", even though when matching "C "the first branch is abandoned before the option setting.
最初の文字に甚いた堎合のみ、クラスを吊定
Without the parentheses, it would match "cataract", "erpillar" or the empty string.
文字クラスを終了する
When the whole pattern matches, that portion of the subject string that matched the subpattern is passed back to the caller via the ovector argument of pcre_exec().
バックスラッシュには、いく぀かの䜿甚法がありたす。たず、 英字でない文字が埌に続く堎合、そお?字が有する 特別な意味は倱われたす。このバックスラッシュの䜿い方は、 文字クラスの内偎ず倖偎の䞡方で䜿甚可胜です。
The fact that plain parentheses fulfil two functions is notThe fact that plain parentheses fulfil two functions is not always helpful.
䟋えば、"*" 文字にマッチさせたい堎合、パタヌンに "\*" を曞きたす。 これにより、次の文字がメタ文字ずしお解釈されようずされたいず、 "\" を䌎った英字でない文字が、その文字自䜓を衚すこずを保蚌したす。 特に、バックスラッシュにマッチさせたい堎合は、"\\" ず曞きたす。
The maximum number of captured substrings is 99, and the maximum number of all subpatterns, both capturing and non-capturing, is 200.
バックスラッシュの2番目の䜿甚法は、出力されない文字を パタヌン内に目に芋える圢で゚ンコヌドする手法を提䟛するものです。 パタヌンを終了させるヌル文字を陀き、出力されない文字の芋え方に は䜕の制玄もありたせんが、パタヌンをテキスト線集する際には、通垞 次の゚スケヌプシヌケンスを甚いる方が、元のバむナリ文字よりも より簡単でしょう。
Thus the two patterns (?i:saturday_BAR_sunday) (? :(?i)saturday_BAR_sunday)Thus the two patterns (?i:saturday_BAR_sunday) (? :(?i)saturday_BAR_sunday) match exactly the same set of strings.
アラヌム、ベル文字 (16進 07)
The numbers must be less than 65536, and the first must beThe numbers must be less than 65536, and the first must be less than or equal to the second.
"control-x", ただし x はあらゆる文字
Thus [aeiou]{3,} matches at least 3 successive vowels, but may match many more, while \d{8}Thus [aeiou]{3,} matches at least 3 successive vowels, but may match many more, while \d{8} matches exactly 8 digits.
゚スケヌプ (16進 1B)
However, because there are cases where this can be useful, such patterns are now accepted, but if any repetition of the subpattern does in fact match no characters, the loop is forcibly broken.
改ペヌゞ (16進 0C)
The classic example of where this gives problems is inThe classic example of where this gives problems is in trying to match comments in C programs.
改行 (16進 0A)
An attempt to match C comments by applying the pattern / \*.*\* / to the string / * first command * / not comment / * second comment * / fails, because it matches the entire string due to the greediness of the .* item.
埩垰 (16進 0D)
The meaning of the various quantifiers is not otherwise changed, just the preferredThe meaning of the various quantifiers is not otherwise changed, just the preferred number of matches.
タブ (16進 09)
When a capturing subpattern is repeated, the value capturedWhen a capturing subpattern is repeated, the value captured is the substring that matched the final iteration.
8進数で ddd の文字たたは埌方参照
However, if there are nested capturing subpatterns, the corresponding capturedHowever, if there are nested capturing subpatterns, the corresponding captured values may have been set in previous iterations.
"\cx" の正確な効果は、次のようになりたす。"x" が小文字の堎合、 倧文字に倉換されたす。続いお、文字の6ビット目(16進数 40)が 反転されたす。぀たり、"\cz" は16進数の 1A になりたすが、"\c{" は16進数の 3B になり、"\c;" は 16進数の 7B になりたす。
In other words, the parentheses that are referenced need not be to the left ofIn other words, the parentheses that are referenced need not be to the left of the reference for numbers less than 10.
"\x" の埌では、2桁の16進数が読たれたす。(衚す文字は、倧文字でも 小文字でも可です)"\0"では2桁たでの8進数が読みこたれたす。 䞡方のケヌスずも、2桁より少ない堎合、衚しおいる文字自䜓が 䜿甚されたす。぀たり、"\0\x\07" は2぀のヌル文字の埌にベル文字 が続いたものを衚したす。8進数を衚す文字に぀いおは、最初のれロ の埌に2桁の数字を指定するように泚意しお䞋さい。
If caseful matching is in force at the time of the back reference, thenIf caseful matching is in force at the time of the back reference, then the case of letters is relevant.
バックスラッシュの埌に0以倖の数字が続く堎合の凊理は、耇雑です。 文字クラスの倖では、PCRE は続く桁を10進数ずしお読みこみたす。 数字が10よりも小さい堎合、たたは、匏の䞭に倀を取埗した巊括匧が この数以䞊あった堎合、党䜓のシヌケンスは、 埌方 参照 ずしお解釈されたす。この動䜜に関する説明 は、括匧付きのサブパタヌンの説明の埌に行いたす。
For example, the pattern (a_BAR_(bc))\2 always fails if it starts to match "a "rather than "bc".
文字クラスの䞭たたは10進数が9より倧きく、取埗を行ったサブパタヌン がこの数に満たない堎合、PCRE はバックスラッシュの埌から最倧3文字の8進数 を再床読みこみ、その倀の最䞋䜍 8ビットから1バむトを生成したす。 続く桁はそれ自䜓を衚したす。䟋えば、
If the pattern continues with a digit character, then some delimiter must be used to terminate theIf the pattern continues with a digit character, then some delimiter must be used to terminate the back reference.
は空癜の別の衚蚘法です。
At each iteration of the subpattern, the back reference matches the character string corresponding to the previous iteration.
は、同じ意味です。ただし、倀を取埗枈みのサブパタヌンが40個未 満の堎合。
The simple assertions coded as \b,The simple assertions coded as \b, \B, \A, \Z, \z, ^ and $are described above.
は垞に埌方参照です。
There are two kinds: those that look ahead of the current position in the subject string, and those that look behind it.
は埌方参照たたはタブの別の衚蚘法です。
Lookahead assertions start with (?= for positiveLookahead assertions start with (?= for positive assertions and (?! for negative assertions.
は垞にタブです。
Lookbehind assertions start with (? = for positive assertionsLookbehind assertions start with (? = for positive assertions and (?! for negative assertions.
(99 を超える埌方参照はないので) 8進数 113 を衚す文字。
The contents of a lookbehind assertion are restricted such that all the strings it matches must have a fixedThe contents of a lookbehind assertion are restricted such that all the strings it matches must have a fixed length.
は1ビットの䞊びで構成される1バむトです。
Thus (? =bullock_BAR_donkey) is permitted, but (? !dogs ?_BAR_cats ?)Thus (? =bullock_BAR_donkey) is permitted, but (? !dogs ?_BAR_cats?) causes an error at compile time.
は埌方参照たたは、ヌル文字の埌に2぀の文字 "8" および "1" が 続いたものです。
This is an extension compared with Perl 5.005, which requires all branches to match the sameThis is an extension compared with Perl 5.005, which requires all branches to match the same length of string.
3桁を超えお8進数は読みこたれないため、倀が100以䞊の8進数には れロを前に぀けるべきではないこずに泚意しおください。
Lookbehinds in conjunction with once-only subpatterns can be particularly useful for matching at the ends of strings; an example is given at the end of the section on once-only subpatterns.
1バむトの倀を定矩するあらゆるシヌケンスは、文字クラスの内郚 および倖郚で䜿甚可胜です。加えお、文字クラスの内郚ではシヌケンス "\b" はバックスペヌス(16進 0x)ずしお解釈されたす。 文字クラスの倖では、別の意味を有したす。(以䞋を参照䞋さい)
Notice that each of the assertions is applied independentlyNotice that each of the assertions is applied independently at the same point in the subject string.
バックスラッシュの第3の䜿甚法は、包括的な文字型を指定する甚途 です。
This pattern does not match "foo" preceded by six characters, the first of which are digits and the last threeThis pattern does not match "foo "preceded by six characters, the first of which are digits and the last three of which are not "999".
10進数字
However, substring capturing is carried out only for positive assertions, because it does not make sense for negative assertions.
空癜文字
An alternative description is that a subpattern of this type matches the string of characters that an identical standalone pattern would match, if anchored at the current point in the subject string.
゚スケヌプシヌケンスの各組は、党文字の集合を2぀の集合に 分割したす。党おの文字は、各組のうち、片方だ?kマッチしたす。
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.
単語構成文字ずは英字たたは数字たたはアンダヌスコア文字であり、 Perl の "単語" ず成り埗る文字のこずです。 文字および数字の定矩は、PCRE の文字テヌブルにより制埡され、 ロケヌルを指定したマッチを行った堎合には倉わる可胜性がありたす。 ("ロケヌルのサポヌト"を参照䞋さい) 䟋えば、"fr" (フランス語)ロケヌルの堎合、いく぀かの128を超える 文字コヌドの文字は、アクセント付きの文字に䜿甚されおおり、 これらは \w にマッチしたす。
Consider a simple pattern such as abcd$Consider a simple pattern such as abcd$ when applied to a long string which does not match.
これらの文字型シヌケンスは、文字クラスの内倖によらず䜿甚可胜 です。これらは、適圓な型の1文字にマッチしたす。珟圚マッチング を行っおいる䜍眮が怜玢察象文字列の終端である堎合、マッチできる 文字はないので党おのマッチングは倱敗したす。
However, if the pattern is written as ^(? .*)(? =abcd) then there can be no backtracking for the .* item; it canHowever, if the pattern is written as ^(? .*)(? =abcd) then there can be no backtracking for the .* item; it can match only the entire string.
バックスラッシュの第4の䜿甚法は、単玔な蚀明です。 蚀明は、怜玢察象文字列から文字を党く抜き出さずに マッチが特定の䜍眮で生じるずいう拘束条件を指定したす。 より耇雑な蚀明に関するサブパタヌンの䜿甚法を以䞋に説明したす。 バックスラッシュ付きの蚀明は次のものがありたす。
There are two kinds of condition.
怜玢察象の終わりたたは終端の改行 (耇数行モヌドずは独立)
The third part is a conditional subpattern that tests whether the first set of parenthesesThe third part is a conditional subpattern that tests whether the first set of parentheses matched or not.
これらの蚀明は、文字クラスには䜿甚できたせん。(しかし、文字クラスの 䞭では、" \b "には別の意味、぀たり、バックスペヌ ス文字ずいう意味があるこずに泚意しおください)