Trim removes spaces or other predefined characters on both sides of a string. If you specify 2nd parameters (the symbols to be removed), can multiple parameters be removed? But now I'm not sure what kind of symbol will be entered, such as Question Mark, point, pause, and exclamation point. it's impossible to repeat all the symbols? So... trim removes spaces or other pre-defined characters on both sides of the string.
If you specify 2nd parameters (the symbols to be removed), can multiple parameters be removed?
But now I'm not sure what kind of symbol will be entered, such as Question Mark, point, pause, and exclamation point. it's impossible to repeat all the symbols?
So what functions can be used to process all the symbols on both sides of a string?
Reply content:
Trim removes spaces or other predefined characters on both sides of a string.
If you specify 2nd parameters (the symbols to be removed), can multiple parameters be removed?
But now I'm not sure what kind of symbol will be entered, such as Question Mark, point, pause, and exclamation point. it's impossible to repeat all the symbols?
So what functions can be used to process all the symbols on both sides of a string?
You can use preg_replace to replace unnecessary characters with null characters.
Echo preg_replace ('/[! : @ #]/', '',' @ Thi: s! Test # '); ### output this test
This is not just the beginning and end, but all locations will be deleted. if necessary, you need to change the regular expression.
Can I use a regular expression to match the first and last characters and parameterize the matching content and number of times?
1. regular expression matching processing 2. do not use these characters when generating this string
Using regular expressions is the best method,w
It can match all the character classes to exclude special characters.
You can use another method to restrict the Input type to only numbers, letters, and underscores.
Since you are not sure about user input, what do you need to delete. So you are sure you want to confirm the things, so do not use the blacklist, consider the whitelist is relatively simple.
If you want anything, you can only enter anything. The rest will not pass ~