Skip to content

Instantly share code, notes, and snippets.

@lukeholder
Created March 29, 2013 11:33
Show Gist options
  • Save lukeholder/5270331 to your computer and use it in GitHub Desktop.
Save lukeholder/5270331 to your computer and use it in GitHub Desktop.
trying to remove the shortcode tags
#!/bin/env ruby
# encoding: utf-8
text = <<-eos
blablablablabla<p>[caption id="attachment_7055" align="alignleft" width="205"]<a href="http://tenina.com/wp-content/uploads/2013/03/Bunny-with-eggs.jpg"><img class="size-medium wp-image-7055" alt="Little egg garden…hop a long bunny!" src="http://tenina.com/wp-content/uploads/2013/03/Bunny-with-eggs-205x300.jpg" width="205" height="300" /></a> Little egg garden…hop a long bunny![/caption]</p>blablablablabla
eos
newcaptionregex = Regexp.new('\[(\w*?)(.*?)\](.*?<word>)\[\/\1\]')
text.gsub!(newcaptionregex, "\\3")
puts text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment