Trying to remove the apostrophe within a string. Using the code below I've removed the apostrophe and the spaces, can anyone help me fix it so I'm just removing the apostrophe?
return text.gsub!(/\s|"|'/, '')
\s means "whitespace character", and
" represents a quote. If you don't want those in your regular expression, pull them. For debugging help try Rubular for testing.
This means your code should be:
def clean_uniname(text) text.gsub!(/\s|"|'/, '') text end
It's worth noting that
nil if no changes have been made so an explicit return of
text is required here if you're using the return value.