Luke Worth
7/9/2005 3:25:00 PM
On Sun, 2005-07-10 at 00:06 +0900, Daniel Brockman wrote:
> Why not use String#shift, which is O(1)?
Because it doesn't exist :)
irb(main):001:0> "aoeu".shift
NoMethodError: undefined method `shift' for "aoeu":String
from (irb):1
To the people suggesting regex, sorry I did think of that. However it
won't work because of the problem: I want to convert all instances of
dot-space into a single space, and all instances of space-dot into a
single dot. All dots not followed or preceded by spaces (excluding
newline) must be turned into newlines.
For example, how would you solve the following:
"bla.h+aoeu.++test.\n+.hello" (where + represents a space)
i think it's hard.
Thanks for your help everyone, I think I've figured out how to do it
with a queue structure though.
--
Luke Worth