Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/commons/ruby/string.rb

Instance Method Summary collapse

Instance Method Details

#replace_all(pattern, replace) ⇒ Object

java.lang.String#replaceAll (Java-like signature)



47
48
49
50
51
52
53
54
# File 'lib/commons/ruby/string.rb', line 47

def replace_all(pattern, replace)
  result = self.gsub(pattern, replace)
  if result == nil
    return self
  else
    return result
  end
end

#substring(begin_index, end_index = nil) ⇒ Object

java.lang.String#substring (Java-like signature)



37
38
39
40
41
42
43
# File 'lib/commons/ruby/string.rb', line 37

def substring(begin_index, end_index = nil)
  if end_index == nil
    return self[begin_index .. -1]
  else
    return self[begin_index ... end_index]
  end
end