William James wrote: > Andrew Johnson wrote: >> If I am reading your specs correctly: >> >> /^(((?!\[joe\]).)*(\[joe\]((?!\[joe\]).)+\[\/joe\])){1,3}((?!\[joe\]).)*$/ > > [ > "good [joe] [/joe] [joe] [/joe]", > "bad [/joe] [joe] [/joe]", > "bad [joe] [/joe] [/joe]" > ].each { |s| > p s =~ > /^(((?!\[joe\]).)*(\[joe\]((?!\[joe\]).)+\[\/joe\])){1,3}((?!\[joe\]).)*$/ > } Quite right: [ "good [joe] [/joe] [joe] [/joe]", "bad [/joe] [joe] [/joe]", "bad [joe] [/joe] [/joe]" ].each { |s| p s if s =~ /^(((?!\[\/?joe\]).)*(\[joe\]((?!\[\/?joe\]).)+\[\/joe\])){1,3}((?!\[\/?joe\]).)*$/ } cheers andrew -- Posted via http://www.ruby-forum.com/.