This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
get-src with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Get the 'src' value from any string containing a src="" (embed, iframe, html, etc).
$ npm install --save get-src
const getSrc = require('get-src'); getSrc('<image src="image.png" />'); //=> 'image.png' getSrc('<iframe width="400" height="300" src="video.mp4"></iframe>'); //=> 'video.mp4'
The string containing the
src="" from which you want to extract the src value.
Currently, there is only support for double quotes, meaning the value you want to extract must rest inside two double quotes:
src="this is valid"
src='this will return undefined'
Pull requests are welcome if you want to add support for double AND single quotes.
MIT © Michael Wuergler