fork download
  1. import re
  2. regex = r"\[caption.*?](.*?)\[/caption]"
  3. test_str = "[caption id=\"attachment_1749417\" align=\"aligncenter\" width=\"426\"][![femur head cross section](http://w...content-available-to-author-only...d.com/wp-content/uploads/2015/03/femur-head-cross-section.png)](http://w...content-available-to-author-only...y.com/107/illus247.html) A cross-section of the top of the thigh bone. ![](http://w...content-available-to-author-only...d.com/wp-content/themes/Phoenix/assets/images/gallery-cam@2x.png) [Gray's Anatomy](http://w...content-available-to-author-only...y.com/107/illus247.html) / Public Domain[/caption]"
  4. match = re.search(regex, test_str)
  5. if match:
  6. print(match.group(1))
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
[![femur head cross section](http://w...content-available-to-author-only...d.com/wp-content/uploads/2015/03/femur-head-cross-section.png)](http://w...content-available-to-author-only...y.com/107/illus247.html) A cross-section of the top of the thigh bone. ![](http://w...content-available-to-author-only...d.com/wp-content/themes/Phoenix/assets/images/gallery-cam@2x.png) [Gray's Anatomy](http://w...content-available-to-author-only...y.com/107/illus247.html) / Public Domain