Jquery Extract URL from Text

こ雲淡風輕ζ 提交于 2019-12-02 02:50:24

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]

The easiest thing to do is to use a regexp, like everyone has pointed to.

/url = \{([^}]*)\}/

That regexp should do it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!