[英]How to match all character exept dot using regexp in ruby?
Given string: 给定字符串:
I can haz kittens. Mmmm. Tasty, tasty kittens.
I need get: 我需要得到:
#without dot
I can haz kittens Mmmm Tasty, tasty kittens
I write: 我写:
string = 'I can haz kittens. Mmmm. Tasty, tasty kittens.'
/[^\.]*/.match(string)
Next,I don't know. 接下来,我不知道。
You just need String#delete
: 您只需要
String#delete
:
"I can haz kittens. Mmmm. Tasty, tasty kittens.".delete('.')
If you really want to use a Regex, you can use String#gsub
: 如果您确实想使用正则表达式,则可以使用
String#gsub
:
"I can haz kittens. Mmmm. Tasty, tasty kittens.".gsub(/\./,'')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.