Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

Ruby regular expressions

str = "Ruby programming language is amazing!"

//.class  # => Regexp 

str =~ /R/    	#return the index of the first occurrence => 0
str =~ /m/	# => 11
/ing/ =~ str	# you can also flip it around => 13
"sky" =~ /[aeiou]/  # you can use a list of characters to match => nil
"love" =~ /[aeiou]/ # => 1
"%^%$%$" =~ /[a..z]/  # => nil

Source by www.rubyguides.com #
 
PREVIOUS NEXT
Tagged: #Ruby #regular #expressions
ADD COMMENT
Topic
Name
7+6 =