Skip to main content
Known Participant
August 26, 2013
Answered

Not loading the .png images

  • August 26, 2013
  • 2 replies
  • 1301 views

I am loading the images from RSS feed, it works perfectly with .jpg images, but not .png or any other formates. here is my code:

function getImgUrl(str:String):String {

    var pattern:RegExp = /src=\"([^\"]+\.jpg|gif|tiff|jpeg|png)/ig;

can some one help Me please.

thanks,

Naveen

This topic has been closed for replies.
Correct answer Andrei1-bKoviI

Expression is missing brackets - it needs to group alterations. It should be:

/src=\"([^\"]+\.(jpg|gif|tiff|jpeg|png))/ig;

2 replies

Andrei1-bKoviICorrect answer
Inspiring
August 26, 2013

Expression is missing brackets - it needs to group alterations. It should be:

/src=\"([^\"]+\.(jpg|gif|tiff|jpeg|png))/ig;

Known Participant
August 26, 2013

working perfectly    thank you very much Andrei

Inspiring
August 26, 2013

You're welcome.

Inspiring
August 26, 2013

first test if it works if you exchange the positions of your jpg/png file formats inside your regular Expression.

if yes: then sth in the syntax of your pattern is faulty

if no: somehow your application can only work with jpg images (look how to use PNGEncoder in a as3)

Known Participant
August 26, 2013

Hi Moccamaximum,

I exchanged the position of jpg/png  and it works only for png images, here is the code:

var pattern:RegExp = /src=\"([^\"]+\.png|gif|tiff|jpeg|png)/ig;

I think im missing somthing on my syntax for identifing all the formates of images (jpg/png/tiff/gif/jpeg).

Inspiring
August 26, 2013

I´m really no expert in regExp, sorry, hopefully some on this forum that are, will read your post ;-)