This is my embed url
<a title="View Skittles Brand Book on Scribd" **href="http://www.scribd.com/doc/32214928/Skittles-Brand-Book"** style="margin: 12px auto 6px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; displa开发者_如何学Goy: block; text-decoration: underline;">Skittles Brand Book</a><iframe class="scribd_iframe_embed" src="http://www.scribd.com/embeds/32214928/content?start_page=1&view_mode=list&access_key=key-10htmr9272mhv32jzem8" data-auto-height="true" data-aspect-ratio="1.1858407079646" scrolling="no" id="doc_15097" width="100%" height="600" frameborder="0"></iframe><script type="text/javascript">(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();</script>
How to pick id from this embed code?
Here is a javascript solution:
var result = inputString.match(/id="([^"]*)/);
alert(result[1]);
This searches for the string id="
and then match everything that is not a "
, this part is put into a capturing group becasue of the brackets around it, you find this then in result[1]
.
be careful if there are more than one id="
in your string.
Here is a working example: JSFiddle (I removed the script part from the end of the example string)
try this regex
(?<=id=")[a-z\_0-9]+
It will give you the value of id
from your embedded code
精彩评论