From: Andy Elvey Date: 2009-03-23T15:24:07+09:00 Subject: Defining a "followed by" operator or function in Ruby Hi all - As part of doing a parsing lib in Ruby, I want to create a "followed by" operator or function. In other words, I want to be able to specify that (say) "foo" must be followed by n or more occurrences of "bar". Something like this - "foo".(0,+) "bar" would match zero or more occurrences of "foo" followed by "bar". So, it would match "foo" , "foo" "bar", "foo" "bar" "bar" ... and so on. "foo".(0,1) "bar" would match zero or one occurrences of "foo" followed by "bar". So, how could this be done? Very many thanks in advance! - Andy -- Posted via http://www.ruby-forum.com/.