From: Peter Szinek Date: 2008-11-13T20:34:12+09:00 Subject: Re: '#' characters are breaking my regexp --Apple-Mail-2--839080049 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Max, > I'm trying to build a regexp that includes music notes, eg Bb or C#. > However, the '#' character is breaking them - basically it just stops > reading the string as soon as it gets to a #: > >>> string = "(Ab|Bb|Db|Eb|Gb|A#|C#|D#|F#|G#|A|B|C|D|E|F|G)" > => "(Ab|Bb|Db|Eb|Gb|A#|C#|D#|F#|G#|A|B|C|D|E|F|G)" >>> regex = Regexp.new(string) > => AbBbDbEbGbA Strange... it works for me: >> string = "(Ab|Bb|Db|Eb|Gb|A#|C#|D#|F#|G#|A|B|C|D|E|F|G)" => "(Ab|Bb|Db|Eb|Gb|A#|C#|D#|F#|G#|A|B|C|D|E|F|G)" >> /#{string}/ => /(Ab|Bb|Db|Eb|Gb|A#|C#|D#|F#|G#|A|B|C|D|E|F|G)/ >> Regexp.new(string) => /(Ab|Bb|Db|Eb|Gb|A#|C#|D#|F#|G#|A|B|C|D|E|F|G)/ what's your Ruby version? as far as I can remember, # should have no special meaning (unless followed by a { when it is an interpolation ) so I am not sure what's going on... Cheers, Peter ___ http://www.rubyrailways.com --Apple-Mail-2--839080049--