tags:

views:

45

answers:

2

At the moment I am using this line to take a string and extract only the letters from it:

string.scan(/[a-zA-Z]/).to_s

How do I modify this so that the underline character, "_", is also included? Thanks for reading.

+7  A: 

Add it within the brackets (the range IIRC).

string.scan(/[a-zA-Z_]/).to_s
alex
+5  A: 

Alternative version

string.scan(/[a-z_]/i).to_s
Diadistis