M
Martin DeMello
I'm trying to match sequences of capitalised words - can someone
explain why the second regexp works but not the first?
irb(main):001:0> a = "And then we Went to The Next Place to be"
=> "And then we Went to The Next Place to be"
irb(main):002:0> a.scan /([A-Z]\w+\s+)+/
=> [["And "], ["Went "], ["Place "]]
irb(main):003:0> a.scan /(?:[A-Z]\w+\s+)+/
=> ["And ", "Went ", "The Next Place "]
martin
explain why the second regexp works but not the first?
irb(main):001:0> a = "And then we Went to The Next Place to be"
=> "And then we Went to The Next Place to be"
irb(main):002:0> a.scan /([A-Z]\w+\s+)+/
=> [["And "], ["Went "], ["Place "]]
irb(main):003:0> a.scan /(?:[A-Z]\w+\s+)+/
=> ["And ", "Went ", "The Next Place "]
martin