|
414 | 414 | # |
415 | 415 | # Lookahead anchors: |
416 | 416 | # |
417 | | -# * `(?=*pat*)`: Positive lookahead assertion: ensures that the following |
| 417 | +# * `(?=_pat_)`: Positive lookahead assertion: ensures that the following |
418 | 418 | # characters match *pat*, but doesn't include those characters in the |
419 | 419 | # matched substring. |
420 | 420 | # |
421 | | -# * `(?!*pat*)`: Negative lookahead assertion: ensures that the following |
| 421 | +# * `(?!_pat_)`: Negative lookahead assertion: ensures that the following |
422 | 422 | # characters *do not* match *pat*, but doesn't include those characters in |
423 | 423 | # the matched substring. |
424 | 424 | # |
425 | 425 | # Lookbehind anchors: |
426 | 426 | # |
427 | | -# * `(?<=*pat*)`: Positive lookbehind assertion: ensures that the preceding |
| 427 | +# * `(?<=_pat_)`: Positive lookbehind assertion: ensures that the preceding |
428 | 428 | # characters match *pat*, but doesn't include those characters in the |
429 | 429 | # matched substring. |
430 | 430 | # |
431 | | -# * `(?<!*pat*)`: Negative lookbehind assertion: ensures that the preceding |
| 431 | +# * `(?<!_pat_)`: Negative lookbehind assertion: ensures that the preceding |
432 | 432 | # characters do not match *pat*, but doesn't include those characters in the |
433 | 433 | # matched substring. |
434 | 434 | # |
435 | 435 | # The pattern below uses positive lookahead and positive lookbehind to match |
436 | | -# text appearing in **...** tags without including the tags in the match: |
| 436 | +# text appearing in `<b>`...`</b>` tags without including the tags in the match: |
437 | 437 | # |
438 | 438 | # /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favors the <b>bold</b>.") |
439 | 439 | # # => #<MatchData "bold"> |
|
577 | 577 | # re.match('1943-02-04').size # => 1 |
578 | 578 | # re.match('foo') # => nil |
579 | 579 | # |
580 | | -# Adding one or more pairs of parentheses, `(*subexpression*)`, defines |
| 580 | +# Adding one or more pairs of parentheses, `(_subexpression_)`, defines |
581 | 581 | # *groups*, which may result in multiple matched substrings, called *captures*: |
582 | 582 | # |
583 | 583 | # re = /(\d\d\d\d)-(\d\d)-(\d\d)/ |
|
649 | 649 | # |
650 | 650 | # * For a large number of groups: |
651 | 651 | # |
652 | | -# * The ordinary `\*n`* notation applies only for *n* in range (1..9). |
653 | | -# * The `MatchData[*n*]` notation applies for any non-negative *n*. |
| 652 | +# * The ordinary `\_n_` notation applies only for *n* in range (1..9). |
| 653 | +# * The `MatchData[_n_]` notation applies for any non-negative *n*. |
654 | 654 | # |
655 | 655 | # * `\0` is a special backreference, referring to the entire matched string; |
656 | 656 | # it may not be used within the regexp itself, but may be used outside it |
|
662 | 662 | # #### Named Captures |
663 | 663 | # |
664 | 664 | # As seen above, a capture can be referred to by its number. A capture can also |
665 | | -# have a name, prefixed as `?<*name*>` or `?'*name*'`, and the name (symbolized) |
| 665 | +# have a name, prefixed as `?<_name_>` or `?'_name_'`, and the name (symbolized) |
666 | 666 | # may be used as an index in `MatchData[]`: |
667 | 667 | # |
668 | 668 | # md = /\$(?<dollars>\d+)\.(?'cents'\d+)/.match("$3.67") |
|
677 | 677 | # /\$(?<dollars>\d+)\.(\d+)/.match("$3.67") |
678 | 678 | # # => #<MatchData "$3.67" dollars:"3"> |
679 | 679 | # |
680 | | -# A named group may be backreferenced as `\k<*name*>`: |
| 680 | +# A named group may be backreferenced as `\k<_name_>`: |
681 | 681 | # |
682 | 682 | # /(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy') |
683 | 683 | # # => #<MatchData "ototo" vowel:"o"> |
|
733 | 733 | # |
734 | 734 | # #### Subexpression Calls |
735 | 735 | # |
736 | | -# As seen above, a backreference number (`\*n`*) or name (`\k<*name*>`) gives |
| 736 | +# As seen above, a backreference number (`\_n_`) or name (`\k<_name_>`) gives |
737 | 737 | # access to a captured *substring*; the corresponding regexp *subexpression* may |
738 | | -# also be accessed, via the number (`\\g*n`*) or name (`\g<*name*>`): |
| 738 | +# also be accessed, via the number (`\\g<i>n</i>`) or name (`\g<_name_>`): |
739 | 739 | # |
740 | 740 | # /\A(?<paren>\(\g<paren>*\))*\z/.match('(())') |
741 | 741 | # # ^1 |
|
770 | 770 | # |
771 | 771 | # #### Conditionals |
772 | 772 | # |
773 | | -# The conditional construct takes the form `(?(*cond*)*yes*|*no*)`, where: |
| 773 | +# The conditional construct takes the form `(?(_cond_)_yes_|_no_)`, where: |
774 | 774 | # |
775 | 775 | # * *cond* may be a capture number or name. |
776 | 776 | # * The match to be applied is *yes* if *cond* is captured; otherwise the |
777 | 777 | # match to be applied is *no*. |
778 | | -# * If not needed, `|*no`* may be omitted. |
| 778 | +# * If not needed, `|_no_` may be omitted. |
779 | 779 | # |
780 | 780 | # Examples: |
781 | 781 | # |
|
804 | 804 | # |
805 | 805 | # #### Unicode Properties |
806 | 806 | # |
807 | | -# The `/\p{*property_name*}/` construct (with lowercase `p`) matches characters |
| 807 | +# The `/\p{_property_name_}/` construct (with lowercase `p`) matches characters |
808 | 808 | # using a Unicode property name, much like a character class; property `Alpha` |
809 | 809 | # specifies alphabetic characters: |
810 | 810 | # |
|
1038 | 1038 | # |
1039 | 1039 | # Each of these modifiers sets a mode for the regexp: |
1040 | 1040 | # |
1041 | | -# * `i`: `/*pattern*/i` sets [Case-Insensitive |
| 1041 | +# * `i`: `/_pattern_/i` sets [Case-Insensitive |
1042 | 1042 | # Mode](rdoc-ref:Regexp@Case-Insensitive+Mode). |
1043 | | -# * `m`: `/*pattern*/m` sets [Multiline Mode](rdoc-ref:Regexp@Multiline+Mode). |
1044 | | -# * `x`: `/*pattern*/x` sets [Extended Mode](rdoc-ref:Regexp@Extended+Mode). |
1045 | | -# * `o`: `/*pattern*/o` sets [Interpolation |
| 1043 | +# * `m`: `/_pattern_/m` sets [Multiline Mode](rdoc-ref:Regexp@Multiline+Mode). |
| 1044 | +# * `x`: `/_pattern_/x` sets [Extended Mode](rdoc-ref:Regexp@Extended+Mode). |
| 1045 | +# * `o`: `/_pattern_/o` sets [Interpolation |
1046 | 1046 | # Mode](rdoc-ref:Regexp@Interpolation+Mode). |
1047 | 1047 | # |
1048 | 1048 | # Any, all, or none of these may be applied. |
1049 | 1049 | # |
1050 | 1050 | # Modifiers `i`, `m`, and `x` may be applied to subexpressions: |
1051 | 1051 | # |
1052 | | -# * `(?*modifier*)` turns the mode "on" for ensuing subexpressions |
1053 | | -# * `(?-*modifier*)` turns the mode "off" for ensuing subexpressions |
1054 | | -# * `(?*modifier*:*subexp*)` turns the mode "on" for *subexp* within the group |
1055 | | -# * `(?-*modifier*:*subexp*)` turns the mode "off" for *subexp* within the |
| 1052 | +# * `(?_modifier_)` turns the mode "on" for ensuing subexpressions |
| 1053 | +# * `(?-_modifier_)` turns the mode "off" for ensuing subexpressions |
| 1054 | +# * `(?_modifier_:_subexp_)` turns the mode "on" for *subexp* within the group |
| 1055 | +# * `(?-_modifier_:_subexp_)` turns the mode "off" for *subexp* within the |
1056 | 1056 | # group |
1057 | 1057 | # |
1058 | 1058 | # Example: |
|
1168 | 1168 | # A regular expression containing non-US-ASCII characters is assumed to use the |
1169 | 1169 | # source encoding. This can be overridden with one of the following modifiers. |
1170 | 1170 | # |
1171 | | -# * `/*pat*/n`: US-ASCII if only containing US-ASCII characters, otherwise |
| 1171 | +# * `/_pat_/n`: US-ASCII if only containing US-ASCII characters, otherwise |
1172 | 1172 | # ASCII-8BIT: |
1173 | 1173 | # |
1174 | 1174 | # /foo/n.encoding # => #<Encoding:US-ASCII> |
1175 | 1175 | # /foo\xff/n.encoding # => #<Encoding:ASCII-8BIT> |
1176 | 1176 | # /foo\x7f/n.encoding # => #<Encoding:US-ASCII> |
1177 | 1177 | # |
1178 | | -# * `/*pat*/u`: UTF-8 |
| 1178 | +# * `/_pat_/u`: UTF-8 |
1179 | 1179 | # |
1180 | 1180 | # /foo/u.encoding # => #<Encoding:UTF-8> |
1181 | 1181 | # |
1182 | | -# * `/*pat*/e`: EUC-JP |
| 1182 | +# * `/_pat_/e`: EUC-JP |
1183 | 1183 | # |
1184 | 1184 | # /foo/e.encoding # => #<Encoding:EUC-JP> |
1185 | 1185 | # |
1186 | | -# * `/*pat*/s`: Windows-31J |
| 1186 | +# * `/_pat_/s`: Windows-31J |
1187 | 1187 | # |
1188 | 1188 | # /foo/s.encoding # => #<Encoding:Windows-31J> |
1189 | 1189 | # |
@@ -1926,7 +1926,7 @@ class Regexp |
1926 | 1926 | # rdoc-file=re.c |
1927 | 1927 | # - ~ rxp -> integer or nil |
1928 | 1928 | # --> |
1929 | | - # Equivalent to *`rxp* =~ $_`: |
| 1929 | + # Equivalent to `<i>rxp</i> =~ $_`: |
1930 | 1930 | # |
1931 | 1931 | # $_ = "input data" |
1932 | 1932 | # ~ /at/ # => 7 |
|
0 commit comments