P
Patrick Gundlach
Dear Ruby-Hackers,
i'd like to catch a malformed regular expression like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#!/usr/bin/ruby
begin
"abcd" =~ /*foo*/
rescue StandardError
puts "error"
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The above does not work (-:4: invalid regular expression; there's no
previous pattern, to which '*' would define cardinality at 1: /*foo*/)
How do I catch this correctly?
Patrick
i'd like to catch a malformed regular expression like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#!/usr/bin/ruby
begin
"abcd" =~ /*foo*/
rescue StandardError
puts "error"
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The above does not work (-:4: invalid regular expression; there's no
previous pattern, to which '*' would define cardinality at 1: /*foo*/)
How do I catch this correctly?
Patrick