Class: Regexp

Inherits:
Object
  • Object
show all
Defined in:
lib/old/old_executor.rb,
lib/rust/parsers/bash/stdlibext.rb,
lib/naksh/stdlibext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_perl(perl_compatible_regexp) ⇒ Object

This file is part of Naksh.

Naksh is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Naksh 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with Naksh. If not, see <www.gnu.org/licenses/>.

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/naksh/regexp.rb', line 19

def Regexp.from_perl(perl_compatible_regexp)
  raise NotImplementedError
end

.from_posix(posix_compatible_regexp) ⇒ Object

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/naksh/regexp.rb', line 24

def Regexp.from_posix(posix_compatible_regexp)
  raise NotImplementedError
end

.from_unix_expression(unix_expr) ⇒ Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/naksh/regexp.rb', line 29

def Regexp.from_unix_expression(unix_expr)
  raise NotImplementedError
end

.join(re_list, preserve_options = true) ⇒ Object

This file is part of Naksh.

Naksh is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Naksh 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with Naksh. If not, see <www.gnu.org/licenses/>.

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
27
# File 'lib/rust/parsers/bash/stdlibext.rb', line 19

def Regexp.join(re_list,preserve_options=true)
  raise ArgumentError,"Regexp.join: 1st argument should be an array #{re_list}" unless re_list.respond_to? :collect and re_list.respond_to? :join
  re_list.collect! do |re|
    re= Regexp.new(Regexp.escape(re)) if re.kind_of? String
    re= Regexp.new(re) unless re.kind_of? Regexp
    preserve_options ? re.to_s : '(?:'<<re.source<<')'
  end
  Regexp.compile(re_list.join('').gsub(/\(\?[\w\-]*\:\)/,''))
end

Instance Method Details

#+(other) ⇒ Object



29
30
31
# File 'lib/rust/parsers/bash/stdlibext.rb', line 29

def +(other)
  Regexp.join([self,other],false)
end

#from_posix(unix_expr) ⇒ Object



25
26
27
# File 'lib/old/old_executor.rb', line 25

def from_posix(unix_expr)
  Regexp.compile(Regexp.escape(unix_expr).gsub(/\\\?/,'.').gsub(/\\\*/,'.*'))
end