From: "David A. Black" Date: 2007-03-14T06:34:07+09:00 Subject: Re: Regular Expression Help Hi -- On 3/13/07, eddieroger wrote: > I'm trying to write a regular expression for Ruby and running into > roadblocks. I'm not new to the concept of a regex, and have written > many before, but I'm new to implementation in Ruby and working with a > particularly pesky regex. > > The string I need to match is: > *'''ABC'', [[Acronym Definition]] > > The only parts I want to change are the ABC and "Acronym Definition." > So, the asterisk, quotes and brackets should be there, but - to make > it harder - the brackets are optional. Maybe you could do something based on character classes; for example, in the one above, /(\W+)(\w+)(\W+)([\w\s]+)/ would give you ABC and Acronym Definition in $2 and $4. Whether you could use this for similar strings would depend of course on how predictable that pattern was. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)