J
Johnathan Smith
Hi,
i know this is a pretty basic problem but im a newbie so any help would
be greatly appreciated
im trying to write a name class one which returns a first name a
surname, first and second initials
however, i realise i regular expression is needed to go through the name
to produce the correct output. however im unsure of whaty regular
expression to use and whether my class is looking correct in general
anyhelp would be greatly appreciated
thanks
name class:
class Name
def initialize(name)
@fname = name.slice!(rexesp)
@sname = name.slice!(regexp)
@mname = name.slice!(regexp)
def firstname
return @fname
end
def surname
return @sname
end
def firstinitial
return @finitial
end
def firstinitial
return @sinitial
end
i know this is a pretty basic problem but im a newbie so any help would
be greatly appreciated
im trying to write a name class one which returns a first name a
surname, first and second initials
however, i realise i regular expression is needed to go through the name
to produce the correct output. however im unsure of whaty regular
expression to use and whether my class is looking correct in general
anyhelp would be greatly appreciated
thanks
name class:
class Name
def initialize(name)
@fname = name.slice!(rexesp)
@sname = name.slice!(regexp)
@mname = name.slice!(regexp)
def firstname
return @fname
end
def surname
return @sname
end
def firstinitial
return @finitial
end
def firstinitial
return @sinitial
end