How does rn match in PHP regular expressions? For example, a small string, \ r \ n
How to match \ r \ n?
(\ R \ n) + does not seem to work?
Reply to discussion (solution)"/[\ R \ n] +/" must be placed in double quotation marks. otherwise, \ r \ n will be interpreted as \, r, \, n
Or '/[\ x0d \ x0a] + /'
I made a separate string and tried it. it is true, but the problem I encountered is:
I extracted a string from the database. this string contains a line break like \ r \ n, which is output directly to the browser as is. I want to use preg_replace
The two characters cannot be extracted in any way, such as "/(\ r \ n) +/" or replaced as you said, cannot match. The character string has been escaped when it is entered into the database. I'm sure the moderator can answer this question. why? Thank you very much.
"/[\ R \ n] +/" must be placed in double quotation marks. otherwise, \ r \ n will be interpreted as \, r, \, n
Or '/[\ x0d \ x0a] + /'
I made a separate string and tried it. it is true, but the problem I encountered is:
I extracted a string from the database. this string contains a line break like \ r \ n, which is output directly to the browser as is. I want to use preg_replace
The two characters cannot be extracted in any way, such as "/(\ r \ n) +/" or replaced as you said, cannot match. The character string has been escaped when it is entered into the database. I'm sure the moderator can answer this question. why? Thank you very much. Echo base64_encode (the content that you directly extract from the database );
Post result
Transfer
Php provides the nl2br function to do this.
Echo base64_encode (the content that you directly extract from the database );
Post result
Transfer
Php provides the nl2br function to do this.
The nl2br has been tried. it does not work because it is escaped as \ r \ n.
I use str_replace ("\ r \ n ","
", $ String); can be successfully replaced to meet the requirements.
Base64_encode:
W3NpemU9MjBdMjBweOeahOWtl + authorization + WIkue6v1svdV1cclxuW3Nd5Lit5YiS57q/authorization
$s = 'W3NpemU9MjBdMjBweOeahOWtl+S9k1svc2l6ZV1cclxuW2Jd5paH5a2X5Yqg57KXWy9iXVxyXG5baV3lgL7mlpxbL2ldXHJcblt1XeS4i+WIkue6v1svdV1cclxuW3Nd5Lit5YiS57q/Wy9zXVxyXG5bY29sb3I9I2YwMF3nuqLoibJbL2NvbG9yXVxyXG5bdXJsXWh0dHA6Ly93d3cuMTYzLmNvbVsvdXJsXVxyXG5bZW1haWxdcmVkXzAyNkAxNjMuY29tWy9lbWFpbF1cclxuW2ltZ11xcGljLzMvMzAuZ2lmWy9pbWdd';$s = base64_decode($s);echo nl2br(stripcslashes($s));
20 px font
Bold text
Skew
Underline
Dashes
[Color = # f00] Red [/color]
Http://www.163.com <br/> red_026@163.com
$s = 'W3NpemU9MjBdMjBweOeahOWtl+S9k1svc2l6ZV1cclxuW2Jd5paH5a2X5Yqg57KXWy9iXVxyXG5baV3lgL7mlpxbL2ldXHJcblt1XeS4i+WIkue6v1svdV1cclxuW3Nd5Lit5YiS57q/Wy9zXVxyXG5bY29sb3I9I2YwMF3nuqLoibJbL2NvbG9yXVxyXG5bdXJsXWh0dHA6Ly93d3cuMTYzLmNvbVsvdXJsXVxyXG5bZW1haWxdcmVkXzAyNkAxNjMuY29tWy9lbWFpbF1cclxuW2ltZ11xcGljLzMvMzAuZ2lmWy9pbWdd';$s = base64_decode($s);echo nl2br(stripcslashes($s));
20 px font
Bold text
Skew
Underline
Dashes
[Color = # f00] Red [/color]
Http://www.163.com <br/> red_026@163.com
Thank you very much!