T
th8254
How would I write a rescue method to recover from a failed regexp
parsing?
-Thanks
parsing?
-Thanks
I don't think that raises an error. You'd have to check for a nil resultth8254 said:How would I write a rescue method to recover from a failed regexp
parsing?
-Thanks
I don't think that raises an error. You'd have to check for a nil
result instead.
SyntaxError: compile errorre = /[/
SyntaxError: compile errorbegin ?> re = /[/
rescue SyntaxError
puts "Your Regexp is malformed."
end
Your Regexp is malformed.begin ?> re = Regexp.new("[")
rescue RegexpError
puts "Your Regexp is malformed."
end
=20I don't think that raises an error. You'd have to check for a nil
result instead.
SyntaxError: compile errorre =3D /[/
SyntaxError: compile errorbegin ?> re =3D /[/
rescue SyntaxError
puts "Your Regexp is malformed."
end
Your Regexp is malformed.begin ?> re =3D Regexp.new("[")
rescue RegexpError
puts "Your Regexp is malformed."
end
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.