How can I delete special characters?

前端 未结 5 1064
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 06:18

I\'m practicing with Ruby and regex to delete certain unwanted characters. For example:

input = input.gsub(/<\\/?[^>]*>/, \'\')

and fo

5条回答
  •  面向向阳花
    2021-02-02 06:45

    If you just wanted ASCII characters, then you can use:

    original = "aøbauhrhræoeuacå" 
    cleaned = ""
    original.each_byte { |x|  cleaned << x unless x > 127   }
    cleaned   # => "abauhrhroeuac"
    

提交回复
热议问题