mretka has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has joined #ruby
mretka has joined #ruby
cappy has quit [Quit: Leaving]
u0_a115 has joined #ruby
<isene>
I have a string, "test this string" and want to extract parts of the text and capture that text in a variable - removing /s ../ should capture "s st" and leave the string like this "test thiring". What's the best/cleanest way?
smp has quit [Ping timeout: 255 seconds]
u0_a115 has quit [Ping timeout: 260 seconds]
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 246 seconds]
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Client Quit]
Linux_Kerio has joined #ruby
u0_a115 has joined #ruby
u0_a1151 has quit [Ping timeout: 245 seconds]
<gr33n7007h>
isene: you can use String#gsub! and Regexp.last_match
mtm has quit [Read error: Connection reset by peer]
mtm has joined #ruby
Artea has joined #ruby
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 252 seconds]
u0_a115 has joined #ruby
u0_a1151 has quit [Ping timeout: 260 seconds]
u0_a115 has quit [Ping timeout: 246 seconds]
Artea has quit [Ping timeout: 272 seconds]
chen has joined #ruby
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 265 seconds]
u0_a1151 has quit [Ping timeout: 248 seconds]
itaipu has quit [Ping timeout: 260 seconds]
itaipu has joined #ruby
o0x1eef has joined #ruby
o0x1eef has quit [Client Quit]
o0x1eef has joined #ruby
JonR has joined #ruby
Success has joined #ruby
o0x1eef has quit [Quit: Quit]
o0x1eef has joined #ruby
Pixi` has joined #ruby
Pixi has quit [Ping timeout: 252 seconds]
konsolebox has quit [Quit: .]
ih8u1 is now known as ih8u
Starfoxxes has joined #ruby
Vonter has quit [Ping timeout: 265 seconds]
Vonter has joined #ruby
<adam12>
madprops: Beware file.readlines.size on large files.
<adam12>
Since it will read entire string into memory and then create N strings in large Array.
<adam12>
I'd open the file handle and then read smallish chunks, counting newlines within each chunk and incrementing some counter... atleast that's how I would do it naievely without benchmarking. But if you're always expecting small files it might not be worth it.
dstein64- has joined #ruby
dstein64 has quit [Ping timeout: 265 seconds]
dstein64- is now known as dstein64
<havenwood>
madprops: I agree with adam12 that I'd avoid reading lines into an Array when unnecessary. Try just a: File.foreach(filename).count
<havenwood>
That ^ will still iterate through the lines but it'll discard them as it goes by rather than storing them in an Array.
<adam12>
That's a nice clean approach.
user71 has quit [Quit: Leaving]
brw has quit [Remote host closed the connection]
brw has joined #ruby
Linux_Kerio has quit [Ping timeout: 246 seconds]
nmollerup has quit [Quit: Leaving]
polishdub has quit [Ping timeout: 246 seconds]
polishdub has joined #ruby
TomyWork has quit [Remote host closed the connection]
ruby[bot] has quit [Remote host closed the connection]