how do i trim a japanese string with whitespaces on it?

    trim() is supposed to be multibyte safe. But if you are having trouble with it, you might try this (untested):

    function mb_trim($string) {
      $rtn = mb_ereg_replace("[[:space:]]*(.*)[[:space:]]*", "\\\\1", $string);
      return $rtn;
    }
    
    $trimmed = mb_trim($myString);

    I am more familiar with PCRE regexp's than POSIX -- if this doesn't work properly, I suggest looking up [man]mb_ereg_replace[/man] in the manual.

    If someone sees an error in my code, please feel free to fix it for rainer2.

    HTH

      thank you very much for your reply.

      I thought it is a white space but it's not or maybe that is a japanese white space Im confused here, anyway I just copy the said japanese white space and I specify it on the trim function as the character to be trimmed and it work. Below is the said character.

      $string = trim ($string, '~A@')

        Excellent 🙂

        Make sure when you get your problem fixed to mark the thread "resolved."

          Make sure when you get your problem fixed to mark the thread "resolved."

          Ok. Again thanks!

            Write a Reply...