Regex to split BBCode into pieces

前端 未结 4 1948
你的背包
你的背包 2020-11-28 14:24

I have this:

str = \"some html code [img]......[/img] some html code [img]......[/img]\"

and I want to get this:

[\"[img]..         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 14:48

    str = "some html code [img]......[/img] some html code [img]......[/img]"
    p str.split("[/img]").each{|x|x.sub!(/.*\[img\]/,"")}
    

提交回复
热议问题