From: diz rael Date: 2006-01-25T15:07:31+09:00 Subject: subsequence regular expression Hi, I'm trying to extract a certain sequence from a string. Best described by example: s = "5b300ba00260bababababababababababababababababa000bd1007bd10b810ba92" slice^--------------------------------------------^ I want to extract a slice of the string starting from the beginning and extending upto the end of the long "ba" sequence. What I'm trying to do is post-process a large dump of memory from an embedded system. The stack region is initially cleared out to bababa... So after the application finishes, the "dirty" portion gives the depth of the stack. There may be stray "ba" values at various places in memory written during the normal course of the application's execution. In the above example, the "dirty" portion is 5b300ba00260. Anyway, I tried the following: s=~/.+?(ba)+/ $& => "5b300ba" It so happens that a "ba" was created on the stack, so the regexp thinks it ends there, when in fact the string I want it to return is: 5b300ba00260 Is there a regexp that can handle this or is this a fundamentally difficult algorithmic problem (kind of related to longest common subsequence I guess). Any help will be appreciated. Thanks a lot! __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com