Hello All,
I written small function which will check whether string is ending with
number or not.
Below is my code but I’m not getting the desire result.
def check_dot_num(x)
#puts “Dot name is : #{x}”
if “#{x}”.include? “.”
puts “Dot present in directory name: #{x}”
puts “***”
puts “#{x}”.end_with?([/\d/])
if “#{x}”.end_with?([/\d/])
puts “End with Number : #{x}”
else
puts " directory not ending with number : #{x} \n"
end
end
end
I’m passing different values to #{x} are:
cer.000
New Folder
cer.00r
cer.001
But in any case it return value as false (i.e. not able to detect number
value at the end of string.)
Could anyone please help me detecting the problem with my code.
Thanks,
Raj