I am getting output from a FB page notes using the Facebook API. In some notes there is an image and in others there are not. I want to extract the src of the image if it is there.
I am using this regex and it works fine, but the problem is that if a note does not contain an image all fails.
json.data[i].message.match(/src=(.+?[\.jpg|\.gif|\.png]")/)[1]
Can I use some kind of a control structure (if else) to check if a note contains an image before using the regex?
If the note does not contain an image I get this error:
Result of expression 'json.data[i].message.match(/src=(.+?[\\.jpg|\\.gif|\\.png]\")/)' [null] is not an object.
I am using Javascript and Appcelerator.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)