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: Quote onmouseover="this.src='http://www.hln.be/static/nmc/nmc/rp/nav/PW_teaser_wwf2.gif';" Anyone knows? thanks! Link to comment https://forums.phpfreaks.com/topic/222205-regex-4-onmouseover/ Share on other sites More sharing options...
trq Posted December 21, 2010 Share Posted December 21, 2010 What exactly do you want to match? Link to comment https://forums.phpfreaks.com/topic/222205-regex-4-onmouseover/#findComment-1149707 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. Link to comment https://forums.phpfreaks.com/topic/222205-regex-4-onmouseover/#findComment-1149817 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? Link to comment https://forums.phpfreaks.com/topic/222205-regex-4-onmouseover/#findComment-1149823 Share on other sites More sharing options...
sasa Posted January 7, 2011 Share Posted January 7, 2011 try $pattern ='/this.src=\'([^\']+)\'/i'; Link to comment https://forums.phpfreaks.com/topic/222205-regex-4-onmouseover/#findComment-1156418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.