ruby on rails - Regex that gets only initials -
is there way create regex initials without using references? example, want initials
new.york
and regex output
n.y. (or n.y)
so far have following:
.\.[a-za-z]+
this outputs last initial of first word instead of first initial: w.y
.
update**
i'm assigned regexp variable , using =~ test things.
you remove lowercase letters using gsub function,
irb(main):004:0> str = "new.york" => "new.york" irb(main):006:0> str.gsub(/[a-z]+/, "") => "n.y"
Comments
Post a Comment