I need to extract URL from a text using jquery.
Lets say i have sowhere on the page following textarea code
The easiest thing to do is to use a regexp, like everyone has pointed to.
/url = \{([^}]*)\}/
That regexp should do it.
how about this
$(document).ready(function() {
$('#click').click(function(){
var one = document.getElementById('one');
one.value.match(/url ={([^}]*)}/,"");
alert( RegExp.$1);
})
})
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.
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]