yuku / textcomplete

Autocomplete for HTMLTextAreaElement and more.
https://yuku.takahashi.coffee/textcomplete/
MIT License
1.74k stars 303 forks source link

FETCHING HASHTAGS FROM TEXTAREA #275

Closed dasguptahirak closed 8 years ago

dasguptahirak commented 8 years ago

Amazing Plugin. Hats off @yuku-t Is there any function to fetch hashtags from textarea? For example: if a user have type "hi #hirak and #yuku" in the textarea. There would be a function called var tags=$('#myTextArea1').getTags() which will fetch all hashtags and return in the form of array.

i.e tags[0]="hirak" and tags[1]="yuku"

yuku commented 8 years ago

No, but it is easy to implement

$.fn.getTags = function () {
  var regexp = /#(\w+)/g;
  var value = this.val();
  var match = regexp.exec(value);
  var result = [];
  while (match != null) {
    result.push(match[1]);
    match = regexp.exec(value);
  }
  return result;
};
dasguptahirak commented 8 years ago

Thanks a lot @yuku-t