Skip to content

Instantly share code, notes, and snippets.

@hackjutsu
Created September 13, 2016 22:12
Show Gist options
  • Save hackjutsu/b0b96b658b875ffcd026da120e427472 to your computer and use it in GitHub Desktop.
Save hackjutsu/b0b96b658b875ffcd026da120e427472 to your computer and use it in GitHub Desktop.
Demo for using regex in Python
import re
testStr = "//gss0.baidu.com/6b1IcTe9R1gBo1vgoIiO_jowehsv/maps/services/thumbnails?width=525&height=295&quality=100&align=middle,middle&src=http://gss0.baidu.com/7LsWdDW5_xN3otqbppnN2DJv/lvpics/pic/item/8cb1cb134954092315ec8fd29258d109b2de4991.jpg"
pattern = "http.*jpg"
m = re.search(pattern, testStr)
print(m.group(0))
# http://gss0.baidu.com/7LsWdDW5_xN3otqbppnN2DJv/lvpics/pic/item/8cb1cb134954092315ec8fd29258d109b2de4991.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment