Jason Williams
10/19/2003 11:47:00 AM
In article <m2wub1o754.fsf@levana.de>, Patrick Gundlach wrote:
> Dear Ruby-Hackers,
>
> i'd like to catch a malformed regular expression like this:
> "abcd" =~ /*foo*/
> rescue StandardError
> puts "error"
> end
Why would you want to do that? Its an error that can be caught
at compile-time, so why let it go until run-time? You can fool
it into missing the error like this, if you want -
regexString = "*foo*"
begin
"abcd" =~ /#{regexString}/
rescue RegexpError
puts "Oops"
end
....but I don't see what this gains.