From: William James Date: 2005-12-07T10:12:34+09:00 Subject: Re: Question concerning multiline regexps and best practice Oliver Andrich wrote: > This little "baby" does the job. As ruby doesn't have named groups in > regexps, I have to add comment lines (?#...) to document the invidual > groups. This would glutter the thing even more. Now ruby has these nice > HERE documents, %r{...} and so on. I would be happy if I could achieve > something like that. > > msg_rx = %r{ > ^\x01? > (?# comment for the line) > ([a-zA-Z]{3,4})(?P\\d{3,4})\s > (\\d)\s > (?# comment for the line) > ([a-zA-Z]{1,3})\s > (?# comment for the line) > (\\d{1,4})\s > (.*)\r\n* > (.*)\r\n* > \x02 > (?# comment for the line) > (?:(.*)=\\s*\r\n)? > (?# comment for the line) > (.*) > \x03.* > (?# comment for the line) > (\\d{2})(\\d{2})(\\d{2})\s > (?# comment for the line) > ([a-zA-Z]{3})\s > (?# comment for the line) > (\\d{2}) > } Use extended mode: msg_rx = %r{ ^\x01? # comment for the line ([a-zA-Z]{3,4}) (\d{3,4}) \s (\d) \s }x