From: Tim Kynerd Date: 2003-02-13T01:23:37+09:00 Subject: Re: String frustration On Wed, 12 Feb 2003 21:38:47 +0900, Mauricio Fern�ndez wrote: > On Wed, Feb 12, 2003 at 06:42:33PM +0900, Tim Kynerd wrote: >> >> No apologies necessary. I'm not 100% clear on this. >> >> Although I think I understand what's going on here, it leaves me >> wondering what would be a better way to do what I need to do, if there >> is a better way. >> >> The input file contains three tab-separated fields. The second field >> needs to be able to contain an arbitrary number of newlines (which will >> be realized as actual newlines, so to speak, when this field is later >> printed out). >> >> > You want multi-line regex mode! > >>> a ="1\tsecond field\nwith newlines\nbla\nbla\tthird\n" > => "1\tsecond field\nwith newlines\nbla\nbla\tthird\n" >>> puts a > 1 second field > with newlines > bla > bla third > => nil >>> re = %r{([^\t]+)\t([^\t]+)\t([^\t]+)\n}m > => /([^\t]+)\t([^\t]+)\t([^\t]+)\n/m >>> a =~ re > => 0 >>> p $1, $2, $3 > "1" > "second field\nwith newlines\nbla\nbla" "third" > => nil No offense, but if I wanted THAT, I'd be using Perl. Thanks anyway. -- Tim Kynerd Sundbyberg (sm�stan i storstan), Sweden tim@tram.nu Sunrise in Stockholm today: 7:39 Sunset in Stockholm today: 16:24 My rail transit photos at http://www.kynerd.nu