dhruvasa` has quit [Remote host closed the connection]
donofrio has joined #ruby
grenierm has quit [Quit: Client closed]
Linux_Kerio has quit [Ping timeout: 252 seconds]
DuckZ has quit [Quit: Disconnected - going offline]
King_DuckZ has joined #ruby
user71 has joined #ruby
kiwi_36 has quit [Read error: Connection reset by peer]
dhruvasagar has joined #ruby
donofrio has quit [Ping timeout: 245 seconds]
donofrio has joined #ruby
<isene>
I'm in need of some advanced regex magic; I need this: "aaa bbb ccc/'ddd eee/fff ggg' hhh/jjj 'kkk lll'" to become this: ["aaa", "bbb", "ccc/'ddd eee/fff ggg'", "hhh/jjj", "'kkk lll'"] --- I've tried all the combinations that I can think of, like .scan(/(?:\w|\S'[^']*')+/) but I just can't make it work. The purpose is to split a string by space - but not when there is a substring quoted with single
<isene>
quotes. Any wizards in here who can cast a spell in my direction?
hwpplayer1 has joined #ruby
trillion_exabyte has quit [Ping timeout: 255 seconds]
trillion_exabyte has joined #ruby
hwpplayer1 has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.4)]
Guest97 has joined #ruby
Guest97 has quit [Client Quit]
Guest97 has joined #ruby
<adam12>
isene: Does this work? ([^\s']+|'.+?')
donofrio has quit [Ping timeout: 248 seconds]
<kjetilho>
adam12: no, see the third element in desired result.
<kjetilho>
I think this works: x.split(%r{(\S*'.*?'|\s+)}).filter { |e| e !~ %r{^\s*$} }
<kjetilho>
(taking advantage of split returning the split string as well when the pattern is enclosed in parenthesis, and just removing the split strings we don't care about.
<adam12>
kjetilho: Ah yes. I see the difference. Interesting.
pgib has joined #ruby
Guest53 has joined #ruby
Guest53 has quit [Client Quit]
Guest53 has joined #ruby
Guest53 has quit [Client Quit]
Guest97 has quit [Ping timeout: 256 seconds]
Guest53 has joined #ruby
Guest53 has quit [Client Quit]
pgib has quit [Read error: Connection reset by peer]
dhruvasagar has quit [Remote host closed the connection]
desnudopenguino has quit [Ping timeout: 248 seconds]
___nick___ has joined #ruby
Guest53 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
stefanos82 has joined #ruby
Linux_Kerio has joined #ruby
desnudopenguino has joined #ruby
hwpplayer1 has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.4)]
donofrio has joined #ruby
stefanos82 has quit [Quit: Leaving]
donofrio has quit [Ping timeout: 265 seconds]
Guest53 has joined #ruby
Guest53 has quit [Client Quit]
Guest53 has joined #ruby
Guest53 has quit [Read error: Connection reset by peer]
Guest53 has joined #ruby
Guest53 has quit [Client Quit]
hwpplayer1 has joined #ruby
stefanos82 has joined #ruby
hwpplayer1 has quit [Quit: bye]
Artea has quit [Ping timeout: 264 seconds]
Sampersand has joined #ruby
Guest53 has joined #ruby
<isene>
kjetilho: Yes, that works - but I'm a bit worried about performance, and this is the reason I was leaning to .scan - since what I'm actually using is a gsub; See here for the actual code to syntax highlight on the rsh commandline (the .c is an extension to the String class adding colors in terminal); https://gist.github.com/isene/256decf2520f9fd65052e60c00ca630b
<isene>
And with further tweaking... this does it :) .scan(/(?:\S'[^']*'|[^ '])+/)
<Sampersand>
Speaking of regex, I still have yet to find usages of `(?~) lol