Dirk Meijer <hawkman.gelooft / gmail.com> 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|\/|\'|\"|#|$|@]+/

Hm, you said "multiple word chars *or* one of your special chars".  To me 
that sounds as if you want

%r{^(?:\w+|[/'"#$@])}

> and
> /^[^:]([^\w|\/|\'|\"|#|$|@]|:)+/
> and it's not working :-(

You don't want the pipe symbol ("|") inside square brackets because here it 
doesn't mean "or" but is taken literally.  Same holds true for your other RX 
btw.

> can anyone enlighten my troubled mind?
> greetings, Dirk.

If you just want to match all strings that don't match the other RX then you 
could simply use !~ instead of =~:

irb(main):020:0> /foo/ =~ "foo"
=> 0
irb(main):021:0> /foo/ !~ "foo"
=> false

Kind regards

    robert