diff --git a/lib/irb.rb b/lib/irb.rb index 6e572c0f9..70d5a5cb7 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -595,10 +595,13 @@ def each_top_level_statement end end - SIMPLE_COMMAND_REGEXP = /^(?\S+)$/ - COMMAND_WITH_ARGS_REGEXP = /^(?\S+) +(?[^-]\S*)$/ - COMMAND_WITH_FLAGS_REGEXP = /^(?\S+) +(?-[a-zA-Z]+( +\S+)*)$/ - COMMAND_WITH_ARGS_AND_FLAGS_REGEXP = /^(?\S+) +(?[^-]\S*) +(?-[a-zA-Z]+( +\S+)*)$/ + COMMAND_FLAG_REGEXP = /(?-[a-zA-Z]+( +\S+)*)/ + COMMAND_ARG_REGEXP = /(?[^-]\S*)/ + COMMAND_NAME_REGEXP = /(?\S+)/ + SIMPLE_COMMAND_REGEXP = /^#{COMMAND_NAME_REGEXP}$/ + COMMAND_WITH_ARGS_REGEXP = /^#{COMMAND_NAME_REGEXP} +#{COMMAND_ARG_REGEXP}$/ + COMMAND_WITH_FLAGS_REGEXP = /^#{COMMAND_NAME_REGEXP} +#{COMMAND_FLAG_REGEXP}$/ + COMMAND_WITH_ARGS_AND_FLAGS_REGEXP = /^#{COMMAND_NAME_REGEXP} +#{COMMAND_ARG_REGEXP} +#{COMMAND_FLAG_REGEXP}$/ COMMAND_REGEXP = Regexp.union( SIMPLE_COMMAND_REGEXP,