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

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -