From: Joseph McDonald Date: 2002-09-24T01:42:22+09:00 Subject: Re: Regexp: How to Find Legitimate Tokens? WDT> Basically, I want to find in a Ruby source code a token, such as ":", WDT> which is really a token, i.e., it is not inside a comment nor inside a WDT> string. My questions are: Check out ripper: http://www.loveruby.net/archive/ripper/ It can parse ruby code. Here we grab the colons and "defs" from ruby source: #!/usr/local/bin/ruby require 'ripper' class R < Ripper def on__COLON( s ) puts s end def on__def(d, *rest) puts d, (rest.join(" ")) end end R.parse ARGF regards, -joe