Class: PCRE::Regex
- Inherits:
-
Object
- Object
- PCRE::Regex
- Defined in:
- lib/ruby_pcre/regex.rb,
ext/ruby_pcre/ruby_pcre.c
Defined Under Namespace
Classes: RegexpError
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_offset ⇒ Object
readonly
Returns the value of attribute error_offset.
-
#error_text ⇒ Object
readonly
Returns the value of attribute error_text.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #compile(use_jit) ⇒ Object
-
#initialize(pattern, jit: true) ⇒ Regex
constructor
A new instance of Regex.
- #match(str) ⇒ PCRE::Match
-
#match_all(str) ⇒ PCRE::Match
Will yield for every found match.
-
#names ⇒ Object
rb_str_new2(re);.
Constructor Details
#initialize(pattern, jit: true) ⇒ Regex
Returns a new instance of Regex.
6 7 8 9 |
# File 'lib/ruby_pcre/regex.rb', line 6 def initialize(pattern, jit: true) @pattern = pattern compile(jit) end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
3 4 5 |
# File 'lib/ruby_pcre/regex.rb', line 3 def error_code @error_code end |
#error_offset ⇒ Object (readonly)
Returns the value of attribute error_offset.
3 4 5 |
# File 'lib/ruby_pcre/regex.rb', line 3 def error_offset @error_offset end |
#error_text ⇒ Object (readonly)
Returns the value of attribute error_text.
3 4 5 |
# File 'lib/ruby_pcre/regex.rb', line 3 def error_text @error_text end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
3 4 5 |
# File 'lib/ruby_pcre/regex.rb', line 3 def pattern @pattern end |
Instance Method Details
#compile(use_jit) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'ext/ruby_pcre/ruby_pcre.c', line 50 static VALUE regex_compile(VALUE self, VALUE use_jit) { char *re; const char *error_ptr; int error_offset; int error_code; pcre *ptr; int do_use_jit = !(use_jit == Qfalse || use_jit == Qnil); VALUE pattern = rb_ivar_get(self, ivar_pattern); Check_Type(pattern, T_STRING); re = StringValuePtr(pattern); ptr = pcre_compile2(re, PCRE_UTF8 | PCRE_DUPNAMES, &error_code, &error_ptr, &error_offset, NULL); if (ptr) { struct PCRE_INTERNAL *pcre_int = ALLOC(struct PCRE_INTERNAL); VALUE rb_pcre_int; pcre_int->pcre = ptr; // |
#match(str) ⇒ PCRE::Match
18 19 20 |
# File 'lib/ruby_pcre/regex.rb', line 18 def match(str) # This is stub only for indexing end |
#match_all(str) ⇒ PCRE::Match
Will yield for every found match
24 25 26 |
# File 'lib/ruby_pcre/regex.rb', line 24 def match_all(str) # This is stub only for indexing end |
#names ⇒ Object
rb_str_new2(re);
13 14 15 |
# File 'lib/ruby_pcre/regex.rb', line 13 def names # This is stub only for indexing end |