Ruby on rails, how to remove white-space from japanese word?

353 Views Asked by At

I am trying to remove white-space from japanese word.

input   "かいしゃ(会社)"
output  "かいしゃ(会社)"
1

There are 1 best solutions below

7
On BEST ANSWER

The space here is consumed by the parentheses. They are not your regular ASCII parentheses, they are of the "full width" flavor.

If you want to replace them with ASCII parentheses, you can do it like this:

compact_input = input.gsub("\uFF08", '(') # and a similar step for the closing parenthesis

Although this might make your string look weird in japanese (I don't know the language well enough, so can't say)