From: Adam Bender Date: 2009-05-06T14:23:38+09:00 Subject: Matching arbitrary number of fields --0016e6d9a0f5d72eb104693798ee Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I want to parse commands from a text file. The commands are of the form: command "param 1" "param 2" command "param" command "param 1" "param 2" "param 3" Each command will have one or more parameters. Each parameter is enclosed in "" marks, and may be one or more words. Is there a regular expression that will match each command without knowing ahead of time how many parameters there are? I tried something like this: line =~ /^(\S+)(?:\s+\"([^\"]*)")+$/ But that only matches the command and the last parameter; I believe $2 is being overwritten as the match progresses. Is there a way to do this with a single regular expression? Thanks, Adam --0016e6d9a0f5d72eb104693798ee--