On Fri, 13 Jun 2003 07:56:21 +0900
John Johnson <jj5412 / earthlink.net> wrote:

> While all the regexp experts have their ears perked up:
> 
> Is there a way to match multiple words in a sentence in any order with one
> regexp? I.e. I have a configuration file that looks like so:
> 
> label lines 12
> the label is 40 characters wide
> print field piece name at row 2 column 23
> print field piece description at column 13 and row 3
> 
> (Following Pragmatic Programmer's tips #20, 37, 52, 68, and 69 :-))
> 
> I would like to extract the parameter names and values whether row is before
> column (for instance), or someone wrote 'the number of lines on the label
> are 12'. Perhaps I'm being a little to flexible here?
> 
> ADVthanksANCE!

Well, you *could* do something like this:

re = /(column|row) (\d+)/i
"print field pieve name at row 2 column 23".scan(re)                    
# => [["row", "2"], ["column", "23"]]
"print field piece description at column 13 and row 3".scan(re)
# => [["column", "13"], ["row", "3"]]

ri String#scan for more details on scan.

But I'm not exactly sure if this is what you're trying to do. You might be
better off with a full-blown parser: I've never used any of the Ruby parser
packages (Or any parser package for that matter) so I don't how hard that
would be.

Jason Creighton