From: Wes Gamble Date: 2006-08-04T06:31:08+09:00 Subject: Non-greediness in a regex - need some help verifying syntax All, Need some medium - level regex help. Here's my regex: /~\^LNK:[\t\r\n]+?\^~/m I'm trying to find all occurrences of strings in my big string that are between ~^LNK: and ^~ sequences of characters that have at least one tab, form feed, or newline character between those two characters. I use the multiline option so that I can match on the newlines. What I'm seeing is the string that is consumed by this regex spans many many many ~^LNK ^~ pairs so that I am removing a bunch of tabs, newlines, etc. that I don't want to. I understand the concept of greediness in regexes, so I put the ? after the [\t\r\n] sequence. Why is the match spanning so many pairs of the delimiter sequences? Why doesn't regex engine stop attempting to match when it sees that first ^~ after the ~^LNK:? Any help is appreciated. Thanks, Wes -- Posted via http://www.ruby-forum.com/.