Ruby 3.2.1p31 (2023-02-08 revision 31819e82c88c6f8ecfaeb162519bfa26a14b21fd)
|
Public APIs related to rb_cRegexp. More...
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Go to the source code of this file.
Macros | |
#define | rb_memcmp memcmp |
#define | HAVE_RB_REG_NEW_STR 1 |
Functions | |
int | rb_memcicmp (const void *s1, const void *s2, long n) |
Identical to st_locale_insensitive_strcasecmp(), except it is timing safe and returns something different. | |
void | rb_match_busy (VALUE md) |
Asserts that the given MatchData is "occupied". | |
VALUE | rb_reg_nth_defined (int n, VALUE md) |
Identical to rb_reg_nth_match(), except it just returns Boolean. | |
VALUE | rb_reg_nth_match (int n, VALUE md) |
Queries the nth captured substring. | |
int | rb_reg_backref_number (VALUE match, VALUE backref) |
Queries the index of the given named capture. | |
VALUE | rb_reg_last_match (VALUE md) |
This just returns the argument, stringified. | |
VALUE | rb_reg_match_pre (VALUE md) |
The portion of the original string before the given match. | |
VALUE | rb_reg_match_post (VALUE md) |
The portion of the original string after the given match. | |
VALUE | rb_reg_match_last (VALUE md) |
The portion of the original string that captured at the very last. | |
VALUE | rb_reg_new_str (VALUE src, int opts) |
Identical to rb_reg_new(), except it takes the expression in Ruby's string instead of C's. | |
VALUE | rb_reg_new (const char *src, long len, int opts) |
Creates a new Regular expression. | |
VALUE | rb_reg_match (VALUE re, VALUE str) |
This is the match operator. | |
VALUE | rb_reg_match2 (VALUE re) |
Identical to rb_reg_match(), except it matches against rb_lastline_get() (or, the $_ ). | |
int | rb_reg_options (VALUE re) |
Queries the options of the passed regular expression. | |
Public APIs related to rb_cRegexp.
RBIMPL
or rbimpl
are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will. __VA_ARGS__
is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98. Definition in file re.h.
#define HAVE_RB_REG_NEW_STR 1 |
#define rb_memcmp memcmp |
void rb_match_busy | ( | VALUE | md | ) |
Asserts that the given MatchData is "occupied".
MatchData shares its backend storages with its Regexp object. But programs can destructively tamper its contents. Calling this function beforehand shall prevent such modifications to spill over into other objects.
[out] | md | Target instance of rb_cMatch. |
int rb_memcicmp | ( | const void * | s1, |
const void * | s2, | ||
long | n | ||
) |
Identical to st_locale_insensitive_strcasecmp(), except it is timing safe and returns something different.
[in] | s1 | Comparison LHS. |
[in] | s2 | Comparison RHS. |
[in] | n | Comparison shall stop after first n bytes are scanned. |
<0 | s1 is "less" than s2 . |
0 | Both sides converted into lowercase would be identical. |
>0 | s1 is "greater" than s2 . |
Definition at line 92 of file re.c.
Referenced by rb_memcicmp().
Queries the index of the given named capture.
Captures could be named. But that doesn't mean named ones are not indexed. A regular expression can mix named and non-named captures, and they are all indexed. This function converts from a name to its index.
[in] | match | An instance of rb_cMatch. |
[in] | backref | Capture name, in String, Symbol, or Numeric. |
rb_eIndexError | No such named capture. |
Definition at line 1229 of file re.c.
Referenced by rb_reg_backref_number().
This just returns the argument, stringified.
What a poor name.
[in] | md | An instance of rb_cMatch. |
Definition at line 1886 of file re.c.
Referenced by rb_reg_last_match().
This is the match operator.
[in] | re | An instance of rb_cRegexp. |
[in] | str | An instance of rb_cString. |
rb_eTypeError | `str` is not a string. |
rb_eRegexpError | Error inside of Onigmo (unlikely). |
RUBY_Qnil | Match failed. |
otherwise | Matched position (character index inside of str ). |
Regexp.last_match
is updated. $&
, $~
, etc., are updated. Definition at line 3590 of file re.c.
Referenced by rb_reg_match().
Identical to rb_reg_match(), except it matches against rb_lastline_get() (or, the $_
).
[in] | re | An instance of rb_cRegexp. |
rb_eRegexpError | Error inside of Onigmo (unlikely). |
RUBY_Qnil | Match failed or $_ is absent. |
otherwise | Matched position (character index inside of $_ ). |
Regexp.last_match
is updated. $&
, $~
, etc., are updated. Definition at line 3645 of file re.c.
Referenced by rb_reg_match2().
The portion of the original string that captured at the very last.
[in] | md | An instance of rb_cMatch. |
$+
. Definition at line 1960 of file re.c.
Referenced by rb_reg_match_last().
The portion of the original string after the given match.
[in] | md | An instance of rb_cMatch. |
Definition at line 1943 of file re.c.
Referenced by rb_reg_match_post().
The portion of the original string before the given match.
[in] | md | An instance of rb_cMatch. |
$
`. Definition at line 1910 of file re.c.
Referenced by rb_reg_match_pre().
VALUE rb_reg_new | ( | const char * | src, |
long | len, | ||
int | opts | ||
) |
Creates a new Regular expression.
[in] | src | Source code. |
[in] | len | strlen(src) . |
[in] | opts | Options e.g. ONIG_OPTION_MULTILINE. |
Identical to rb_reg_new(), except it takes the expression in Ruby's string instead of C's.
[in] | src | Source code in String. |
[in] | opts | Options e.g. ONIG_OPTION_MULTILINE. |
rb_eRegexpError | `src` and `opts` do not interface. |
Definition at line 3291 of file re.c.
Referenced by rb_reg_new_str(), and rb_reg_regcomp().
Identical to rb_reg_nth_match(), except it just returns Boolean.
This could skip allocating a returning string, resulting in reduced memory footprints if applicable.
[in] | n | Match index. |
[in] | md | An instance of rb_cMatch. |
rb_eTypeError | `md` is not initialised. |
RUBY_Qnil | There is no n -th capture. |
RUBY_Qfalse | There is a n -th capture and is empty. |
RUBY_Qtrue | There is a n -th capture that has something. |
Definition at line 1844 of file re.c.
Referenced by rb_reg_nth_defined().
Queries the nth captured substring.
[in] | n | Match index. |
[in] | md | An instance of rb_cMatch. |
rb_eTypeError | `md` is not initialised. |
RUBY_Qnil | There is no n -th capture. |
otherwise | An allocated instance of rb_cString containing the contents captured. |
Definition at line 1861 of file re.c.
Referenced by rb_reg_last_match(), rb_reg_match_last(), and rb_reg_nth_match().
int rb_reg_options | ( | VALUE | re | ) |
Queries the options of the passed regular expression.
[in] | re | An instance of rb_cRegexp. |
Definition at line 4107 of file re.c.
Referenced by rb_reg_options().