0

In my HTML page I have multiple occurrences of this code:

<a onclick="window.open('hxxp://www.mysite.com/gallery/foto_amatoriali/foto_gallery_prova/foto_amatoriali.jpg');" href="javascript:void(0)">
    <img height="90" alt="foto_amatoriali.jpg" src="hxxp://www.mysite.com/gallery/foto_amatoriali/foto_gallery_prova/th/foto_amatoriali_thumb.jpg" width="120" vspace="4" />
</a>

What I wanna do is with php extract all IMAGE SOURCES LINK

hxxp://www.mysite.com/gallery/foto_amatoriali/foto_gallery_prova/foto_amatoriali.jpg

Between window.open(' and ');

I created this REGEX PATTERN:

open\(\'([^()]*)\'

I tested via an online REGEX edtior and it seems to work but when I do it via php it works not correctly.

In many case it extract not only the link but LINK plus window.open('

Someone can help me with the correct REGEX syntax ?

Thanks

2
  • Are you trying to do this with PHP? What have you tried so far with PHP? Commented Jan 17, 2015 at 15:26
  • 1
    Change your regex to open\(\'([^']*)\'\) and then print the index 1. Commented Jan 17, 2015 at 15:30

1 Answer 1

1

You can use this regex:

(?<=open\(\')([^()]*)(?=\'\))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.