假设我有一个字符串:Hey what's up @dude, @how's it going?
我想删除all之前的字符@how's
.
或使用正则表达式:
str = "Hey what's up @dude, @how's it going?"
str.gsub!(/.*?(?=@how)/im, "") #=> "@how's it going?"
你可以阅读有关环视的信息here http://www.regular-expressions.info/lookaround.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)