Dirk Meijer wrote:

> regexps can be so confusing, i need help on this one..
> - i want one regexp to match a possible colon at the start (but no more),
> followed by multiple word characters, or the following: / ' " # $ @
> - another regular expression should match the opposite, no colon at the
> start (but possibly colon later), followed by characters other than the
> characters shown above.
>  so far, i've got this:
>  /^:?[\w|\/|\'|\"|#|$|@]+/
> and
> /^[^:]([^\w|\/|\'|\"|#|$|@]|:)+/
> and it's not working :-(
> can anyone enlighten my troubled mind?
> greetings, Dirk.

I'd say:

(file test.rb)
if /^:?[\w\/\'\"#$@]*$/.match($_)
  puts $_
end

and to check:
ruby -n test.rb
:blablabla
...