Created
March 29, 2013 11:33
-
-
Save lukeholder/5270331 to your computer and use it in GitHub Desktop.
trying to remove the shortcode tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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