Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一个字符串: string = <.one><.two>three<.four>[:five] ,我该如何操作这个字符串来删除模式“<..>”中的所有内容。我希望我的输出返回;字符串 = 三 [:五]
谢谢
"<.one><.two>three<.four>[:five]".gsub(/<.+?>/, '')
irb(main):002:0> '<.one><.two>three<.four>[:five]'.gsub(/<[^>]*>/,'') => "three[:five]"