I need to extract URL from a text using jquery.
Lets say i have sowhere on the page following textarea code
<textarea rows="20" name="textarea" style="width:100%;">
@techreport{blabl,
blabla = {},
url = {http://server.com/thepdf.pdf},
wrongurl ={http://server.com/thepdf2.pdf},
blablabla = 1998,
blablablabla= {blablablablabla}}
</textarea>
i need the url, and only the url contents - not wrongurl.
Update: it has always the same structure and i only need to extract it ONCE and it always has an "url = {" in front of it.
jQuery won't do this, you're looking for a regular expression to extract the URL from the 'url' property in this textarea. You can do this with the following regex:
/url = \{(.+)\}/.exec(textarea_str)[1]
The easiest thing to do is to use a regexp, like everyone has pointed to.
That regexp should do it.
how about this
or a runnable demo http://jsfiddle.net/PePS7/10/
oops, bit late to the game but ammended the example and the jsfiddle to only show the url
You're going to need to do some Reg ex on this. If I was better at them I'd write one up for you.