I was doing the challenges from pythonchallenge writing code in ruby, specifically this one. It contains a really long string in page source with special characters. I was trying to find a way to delete them/check for the alphabetical chars.
I tried using scan method, but I think I might not use it properly. I also tried delete!
like that:
a = "PAGE SOURCE CODE PASTED HERE"
a.delete! "!", "@" #and so on with special chars, does not work(?)
a
How can I do that?
Thanks
[^A-Za-z ]
works better, in this case. Otherwise, if you have a sentence, which typically should start with a capital letter, you will lose your capital letters. You would also lose any1337 speak
, or other possible crypts within the text. Case in point:phrase = "Joe can't tell between 'large' and large." => "Joe can't tell between 'large' and large."
– Kerenkeresan