Skip to content

Instantly share code, notes, and snippets.

@kmod-midori
Last active December 14, 2015 21:39
Show Gist options
  • Save kmod-midori/5152636 to your computer and use it in GitHub Desktop.
Save kmod-midori/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