1 problem Origin: made a commodity management system. The product name only uses trim to remove the leading and trailing blanks. (Of course, the framework comes with a variety of anti-SQL anti-X functions, which is not the focus) the product name format is as follows: REPLAY women's down jacket 23803
The product name is pretty good. Here's the problem. When searching because there is no going to the middle space. Cause if the middle of the product name is a double space. Can not search out. Negligence of work. Used to write "published article" Such a function is reluctant to go to space (blank).
2 Debugging Road: Found in the browser single space is replaced by a single +, double space replaced by + +. The system has been customer service sister input a lot of products. Tangled.
3 Problem derivation: Just note that some functions can not filter Chinese full-width space on the line.
4 Solution: PHP:
$str = ' REPLAY ladies down jacket 23803 ';
$str =preg_replace ("/\s| /"," ", $str);
Echo $str;
Java:
String str = ' REPLAY ladies down jacket 23803 '; With tabs with Chinese full-width spaces
String str2 = str.replace ((char) 12288, ');
String STR3 = Str2.replaceall ("\\s*|\t|\r|\n", "" ");
System.out.println (STR3);
Can be ligatures. Separate writing is a way of showing ideas.
The small problem of empty, small problem also noisy. Record the