开发者

How to change this Ruby regex to also include underlines?

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, "开发者_StackOverflow社区_", is also included? Thanks for reading.


Add it within the brackets (the range IIRC).

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


Alternative version

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜