Last active
August 29, 2015 14:04
-
-
Save sudodo/6b75f8bc26eaf75596e3 to your computer and use it in GitHub Desktop.
Remove symbol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: utf-8 | |
| def remove_symbol str | |
| wide_symbol = "、 。 , . ・ : ; ? ! ゛ ゜ ´ ` ¨ ^  ̄ _ ヽ ヾ ゝ ゞ 〃 仝 々 〆 〇 ー ― ‐ / \ ~ ∥ | … ‥ ‘ ’ “ ” ( ) 〔 〕 [ ] { } 〈 〉 《 》 「 」 『 』 【 】 + - ± × ÷ = ≠ < > ≦ ≧ ∞ ∴ ♂ ♀ ° ′ ″ ℃ ¥ $ ¢ £ % # & * @ § ☆ ★ ○ ● ◎ ◇ ◆ □ ■ △ ▲ ▽ ▼ ※ 〒 → ← ↑ ↓ 〓" | |
| str.gsub!(/[!-\/:-@\[-`{-~]*/,"") # => remove word consisting of only numeric or special chars like 123, `"$# | |
| str.gsub!(/[#{wide_symbol}]/,"") | |
| # str.gsub!(/[!。、*・]/,"") | |
| str.gsub!(/\p{Symbol}/,"") | |
| str | |
| end | |
| puts remove_symbol "@@@□a****(^・^)□" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment