From: Mike Stok Date: 2006-06-27T08:50:38+09:00 Subject: Re: Unicode roadmap? On 26-Jun-06, at 1:03 PM, Austin Ziegler wrote: > On 6/26/06, Logan Capaldo wrote: >> On Jun 26, 2006, at 2:13 AM, Joel VanderWerf wrote: >> > irb(main):001:0> "It's needlessly cryptic."[/./] >> > => "I" >> > Not disagreeing, just trying to get more credit for regexes. >> > irb(main):010:0> "It's needlessly cryptic."[/.{17}(.)/, 1] >> > => "r" >> > That's a bit more cryptic. >> It's funny I'm always forgetting you can index by regexp. But this >> brings up a good point, this is Ruby, with the new Hash / named >> argument syntax we can do: >> >> "It's needlessly cryptic."[byte:2] >> >> This doesn't add anything at all to the conversation, but I think it >> looks good, and it's in the "make similiar things look similar" vein. >> >> Indexing Strings >> >> s[0] # The first character >> s[/./] # The first character >> s[byte:0] # The first byte (of a string with some non ascii >> compatible encoding) > > I kinda like that. Presumably this is general arm waving, because s[/./] need not return the first character of a non-empty string, unless you mean s[/./m] or some uglier alternative ratdog:~ mike$ irb --simple-prompt >> "\nx"[/./] => "x" >> "\nx"[/./m] => "\n" Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.