Class Regexp
In: EFL_regexp.rb
Parent: Object

Copyright © 2007 by Ruben Heradio Gil, Jose Antonio Cerrada Somolinos, Jose Ramon Coz Fernandez and Jose Carlos Lopez Ruiz. This file is part of EFL-A Ruby implementation of the Exemplar Flexibilization Language. EFL is distributed under the terms of the GNU Lesser General Public License (LGPL). EFL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. EFL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <www.gnu.org/licenses/>. Contact Information: Ruben Heradio Gil (rheradio@issi.uned.es). Phone number: 00 34 91 398 8242, Postal address: Dpto. de Ingeniería de SW y Sistemas Informáticos. E.T.S.I. Informática, UNED. C/ Juan del Rosal, 16. 28040 Madrid.

Extensions of the Ruby regular expressions

The next operators are included:

Methods

-   >   o  

Public Instance methods

Using the "minus operator", regular expressions can be refined by deleting specific patterns. For example, let suppose we have the text: text_1, text_2, text_3, text_4.

The matching of the regular expression /text_[0-9]/ is [‘text_1’, ‘text_2’, ‘text_3’, ‘text_4’].

Applying the - operator: /text_[0-9]/ - /text_1/ - /text_3/, the matching will be refined to [‘text_2’, ‘text_4’].

Note that:

  • re1 - re2 deletes the re2 matchings in the context of re1. That is, re_1 > re_2 > … > re_n - re_minus it would be equivalent to re_1 > re_2 > … > re_n - (re_1 > re_2 > … > re_n > re_minus)
  • To avoid inconsistent expressions, on the right side of the - operator is not permitted the use of the > operator.

Using the "zoom operator", regular expressions can be chained to specify progressively a text pattern.

For example: regular_expression_1 > regular_expression_2 > regular_expression_3 > … regular_expression_N

runs the regular_expression_2 over the selection made by the regular_expression_1,

the regular_expression_3 over the selection made by the regular_expression_2, etcetera

Complements a regular expression. For example: regular_expression_1.o > regular_expression_2 matchs regular_expression_2 outside the text matched by regular_expression_1

Note that:

  • regular_expresion.o.o = regular_expresion
  • (regular_expression_1 > regular_expression_2 > … > regular_expression_N).o = regular_expression_1 > regular_expression_2 > … > regular_expresion_N.o

[Validate]