Ho un array con gli hashtag di Twitter. E voglio filtrare una stringa tw.text
per quelle hashtags e avvolgere le parole in un span
Javascript: testo Sostituisci per più stringhe nell'array?
var hashtags = new Array("home","car", "tree");
tw.text.replace('#home', '<span class="hash">#home</span>')
Come potrei farlo?
Grazie in anticipo.
Perfetto, grazie, c'è anche un modo semplice per verificare la versione "maiuscola" delle parole? Ti piace 'HOME, CAR, TREE'? – matt
Penso che potresti usare 'nuovo RegExp ('#' + elem, 'i')' e poi '.replace (regexp, ' # \ 0')' –