HTML :
<textarea>
http://ex.com=>sitename1=>Fashion
http://some.com=>sitename2=>Sport
</textarea>
<br>
<code></code>
jQuery :
val = $("textarea").text();
obj = val.substr(val.indexOf ( '=>' ) )
$("code").html(obj)
i dont have any idea…
Test here : http://jsfiddle.net/2heTu/
Any way can i get result and use objects like :
- ex.com (sitename1 in Fashion category)
- some.com (sitename2 in Sport category)
- ….. more more more
DEMO
Note
.val()method used.split(/[\r\n]+/)used to get each lines$.each(parts, function(i, val) {..}make loop over each lineswhere
iarguments is the index0,1,2..valholds each linesif(val.length) {..check for empty value$.trim(val)remove spaces$.trim(val).split('=>')split each line with=>and return an array liketemp = ["http://ex.com", "sitename1", "Fashion"]and so onand
temp[0]contains urltemp[1]contains sitenametemp[2]contains category`temp[0].replace('http://', '')removehttp://from url$("code").append(output)append the output to.append('<br>')add new line after each output