Skip to content

Instantly share code, notes, and snippets.

@chengyuhui
Last active December 14, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chengyuhui/5152636 to your computer and use it in GitHub Desktop.
Save chengyuhui/5152636 to your computer and use it in GitHub Desktop.
get_tags = (raw)->
return '' if raw is ''
return '' if !raw?
raw = raw.replace /☪|★|☆/g,''
pattern = /\[(.+?)\]|【(.+?)\】|\((.+?)\)|『(.+?)\』|~(.+?)\~|◆(.+?)◇/g
tmp = raw.match(pattern)
if tmp? then tmp = for val in tmp
val[1...-1]
else tmp = []
_raw = raw.replace(pattern,'').split(/\s+/g)
if _raw? and _raw.length >0 then for val in _raw
if val.replace /\s/g,'' is not val then tmp.push val
tmp = for tag in tmp
tag = tag.replace(/\s|&|&|&|\/|/|_|\|/g,' ')
tag = tag.split(/\s/g)
restore_english = (arr)->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment