Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby replace certain character

# Ruby language
str_old = "first-name last-name"
str_old.sub("-", "_") 		# Replace first "-" with "_"
str_old.gsub("-", "_") 		# Replace all "-" with "_"
Comment

PREVIOUS NEXT
Code Example
Ruby :: how to create migration with uniqueness inrails 
Ruby :: ruby check if block given 
Ruby :: ruby get file name 
Ruby :: find path of module in ruby 
Ruby :: rails disable cache on dev 
Ruby :: ruby loop through array from last item backwards 
Ruby :: ruby array has element 
Ruby :: rails update without validation 
Ruby :: require relative ruby 
Ruby :: rails datatypes 
Ruby :: ruby check if value in array 
Ruby :: conditional operator in ruby 
Ruby :: new date ruby 
Ruby :: default value rails migration 
Ruby :: ruby map array 
Ruby :: Convert Date and time to utc in rails 
Ruby :: ruby array remove by index 
Ruby :: rails transactions 
Ruby :: ruby open file and append 
Ruby :: Rails is not defined 
Ruby :: rails loop through datetime 
Ruby :: ruby frozen_string_literal 
Ruby :: invalid byte sequence in utf-8 ruby 
Ruby :: how to add variable inside string ruby 
Ruby :: ruby rspec change matcher 
Ruby :: sequel ruby different table name 
Ruby :: cant find user without id error in rails 
Ruby :: rails ago 
Ruby :: rails rspec test email sent 
Ruby :: ruby-on-rails 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =