Miko Posted December 20, 2010 Share Posted December 20, 2010 Hello, I don't have much experience with regular expressions so bear with me . I need a regex for an onmouseover function in an image tag. the content will be something like this: onmouseover="this.src='http://www.hln.be/static/nmc/nmc/rp/nav/PW_teaser_wwf2.gif';" Anyone knows? thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted December 21, 2010 Share Posted December 21, 2010 What exactly do you want to match? Quote Link to comment Share on other sites More sharing options...
Miko Posted December 21, 2010 Author Share Posted December 21, 2010 Well it should first start with a this.src=' the rest will be an url of an image that can have any extension, like in the url. Thanks. Quote Link to comment Share on other sites More sharing options...
Miko Posted December 21, 2010 Author Share Posted December 21, 2010 I did some searching on Google and came up with: http://([\w-]+\.)+[\w-]+(/[\w- ./]*)+\.(?:gif|jpg|jpeg|png|bmp|GIF|JPEG|JPG|PNG|BMP|Gif|Jpg|Jpeg|Png|Bmp) Changed it to: this.src='http://([\w-]+\.)+[\w-]+(/[\w- ./]*)+\.(?:gif|jpg|jpeg|png|bmp|GIF|JPEG|JPG|PNG|BMP|Gif|Jpg|Jpeg|Png|Bmp)'; But it's not working Any ideas? Quote Link to comment Share on other sites More sharing options...
sasa Posted January 7, 2011 Share Posted January 7, 2011 try $pattern ='/this.src=\'([^\']+)\'/i'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.