This might not be the right place to put this, if it’s not I do
apologize, but I hope maybe someone here can at least point me in the
I’m currently creating a module to download sports box scores from
websites (in HTML) that will insert the data into databases using regex
and loops so that the data can be further analyzed.
I ran into a problem with the names of some players having non letter
punctuation (commas, periods, apostrophes, dashes, etc…), which I
hadn’t fully expected. I solved the issue of ‘getting’ the names with
the regex, but mysql rejects the inserts into a varchar field with this
non text characters. Right now my solution is to remove the non text
characters on the insert of the athletes name, but then the name is
stored improperly. I know PHP has an ‘escape string’ function that
handles these things automatically. Is there something built in to ruby
to handle something like this. If there isn’t is there a way to write a
gsub that will replace these non text characters with a \ before them,
all at once?
i.e if it’s a “,”, “.”, “-” replace it with , , . , - or do i have to
do each one individually?