From: Brian Candler Date: 2009-06-26T22:44:04+09:00 Subject: Re: regex that works on rubular.com but not in my program Brian Candler wrote: > Don't test them in rubular. Test them in irb or in ruby. In a ruby file, you can comment out bits of them until you make it work, e.g. re = %r{ (?#start: fetch the ip adress after IP) IP\s((?:\d+\.){3}\d{1,3}) (?#end: fetch ip) }x #(?#start: flag).*:\s([PSF])(?#end:flag) #(?#nothing more interesting on this line) #.* # #(?#start: look for index pattern) #^E.{5}@.{9}Q.{30,} #(?#end: index) # #(?#start: get the username which is surrounded by multiple dots, minimum #of 2 in the begining and 0+ after) #\.{2,}(\w+) #(?#end: username) #}x src = "12:23:59.378678 IP 85.225.108.54.54707 > 81.227.132.223.6112: P 590518027:590518071(44) ack 2582330461 win 64240\nE..Te.@.t..U.l6Q.......#2....<]P.........,................wakko0..........@......" p re =~ src p $~.to_a Then you move the }x end of the regular expression and start uncommenting further bits until it starts to fail again, then you know where the problem is. -- Posted via http://www.ruby-forum.com/.