python - Regular expression for a string like this -


i need match strings start with:

'/engine 

and end with:

ir_vrn' 

i have used this:

 vrn_page = re.compile('\'/engine[a-za-z0-9._+-&/?:=]+ir_vrn\'') traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/lib/python2.6/re.py", line 190, in compile     return _compile(pattern, flags)   file "/usr/lib/python2.6/re.py", line 245, in _compile     raise error, v # invalid expression sre_constants.error: bad character range 

but doesn't work string:

'/engine/page/im/pop_mostra.php?p_=9078&p_utentevisitatore=1702795&loto=http://s1.example.com/utloto/9/9078/media/7df4164ecb81a5992280a1ce81120d05-3a5fa4377a23242690a273a82ea5d607&type=ir_vrn' 

try:

/engine.*?ir_vrn

note question mark. makes sure in

/engined&^&^&^&ir_vrn@$@#$@#ir_vrn!@#!@#

it catches

/engined&^&^&^&ir_vrn

rather

/engined&^&^&^&ir_vrn@$@#$@#ir_vrn


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -