Related Articles

Related Articles

Ruby | Regexp inspect() function
  • Last Updated : 17 Dec, 2019

Regexp#inspect() is a Regexp class method which produces a formatted string-version of regualar expression.

Syntax: Regexp.inspect()

Parameter: Regexp values

Return: a formatted string-version of regualar expression

Example #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for Regexp.inspect() method
  
# declaring Regexp value
reg_a = /a/
  
# declaring Regexp value
reg_b = /geeks/
  
# declaring Regexp value
reg_c = /a/
  
  
#  inspect method
puts "Regexp inspect form : #{reg_a.inspect}\n\n"
  
puts "Regexp inspect form : #{reg_b.inspect}\n\n"
  
puts "Regexp inspect form : #{reg_c.inspect}\n\n"

chevron_right


Output :

Regexp inspect form : /a/

Regexp inspect form : /geeks/

Regexp inspect form : /a/

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for Regexp.inspect() method
  
# declaring Regexp value
reg_a = /geeks/
  
# declaring Regexp value
reg_b = /problem/
  
# declaring Regexp value
reg_c = /code/
  
  
#  inspect method
puts "Regexp inspect form : #{reg_a.inspect}\n\n"
  
puts "Regexp inspect form : #{reg_b.inspect}\n\n"
  
puts "Regexp inspect form : #{reg_c.inspect}\n\n"

chevron_right


Output :

Regexp inspect form : /geeks/

Regexp inspect form : /problem/

Regexp inspect form : /code/
My Personal Notes arrow_drop_up
Recommended Articles
Page :