Trim is the removal of whitespace characters or other predefined characters on either side of a string.
If you specify a 2nd parameter (the symbol you want to remove), can you remove more than one?
But now it is not sure what kind of symbol will be entered, such as question mark, dot, comma, exclamation mark, it is impossible to all the symbols to play it again?
So what function can I handle all the symbols on both sides of the string?
Reply content:
Trim is the removal of whitespace characters or other predefined characters on either side of a string.
If you specify a 2nd parameter (the symbol you want to remove), can you remove more than one?
But now it is not sure what kind of symbol will be entered, such as question mark, dot, comma, exclamation mark, it is impossible to all the symbols to play it again?
So what function can I handle all the symbols on both sides of the string?
You can use Preg_replace to replace the characters that are not required to be empty.
echo preg_replace('/[!:@#]/', '', '@thi:s! test#');###输出this test
This is not only the end-to-end, all locations will be deleted, if necessary, the need to change the regular.
Can I use regular expressions to match the kinsoku characters and parameterize the matching content and number of times?
1.正则匹配处理2.生成这个字符串的时候就不要这些字符
Using regular is the best way, you can take a good look, w
you can match all the characters, thus eliminating the special symbol
You can change your mind. Limit input type only allow input alphanumeric underline
既然你不确定用户输入,你需要删除哪些东西。那么你确定要的东西肯定是确定的,所以不要使用黑名单制,考虑白名单比较简单。
就是你要啥,就只允许输入啥,其他都不通过~