Delete textarea carriage return and line feed code: functionremoveNL (s) {NewLine, CarriageReturnandTabcharactersfromaStringwillberemovedandwillreturnthen
Delete textarea carriage return and line feed code:
- Function removeNL (s)
- {
- // NewLine, CarriageReturn and Tab characters from a String
- // Will be removed and will return the new string
-
- R = "";
- For (I = 0; I <s. length; I ++)
- {
- If (s. charAt (I )! = 'N' & s. charAt (I )! = 'R' & s. charAt (I )! ='T '){
- R + = s. charAt (I );
- }
- }
-
- Return r;
- }
Php solution:
Use the php function and str_replace to replace the function, such as str_replace ('N ','
'), The problem is that the replacement was not successful and never been replaced. after a long time, I began to doubt whether the linefeed in textarea was n. now I think it is too shaken, in fact, after I replaced n/n respectively, I intuitively told myself that I had entered a dead end. this is not a solution to the problem. there must be a fundamental error. Suddenly I thought about whether it would be a single quotation mark or double quotation mark, so the str_replace ('N ','
') Changed to str_replace ("n ","
"), The light flashed, and the replacement was successful.
Sequence description:
N: line feed (lf or ascii characters 0 × 0a (10 ))
R: Press enter (cr or ascii character 0 × 0d (13 ))
T: horizontal tab (ht or ascii character 0 × 09 (9 ))
/: Backslash
$: Dollar sign
": Double quotation marks
[0-7] {}: the regular expression sequence matches a character represented by the octal symbol.
X [0-9a-fa-f] {}: this regular expression matches a character in a sequence expressed by a hexadecimal symbol.