我知道有很多关于此的帖子,我保证在发布我自己的版本之前,我已尽可能多地查看。
我从续集中拉出一个电子邮件正文并将其粘贴到excel中作为更大项目的一部分。每次将此值粘贴到excel中时,它会保留所有换行符,从而扭曲更大的数据集。
这些特定的电子邮件中有大量丑陋的HTML似乎在玷污这些作品。
TLDR:我在下面的select语句中遗漏了什么,这可以帮助我在从续集到Excel时粘贴多行时删除这些无关的换行符和其他格式。
由于replace()
函数似乎都无法解决这个问题,所以有人帮助我吗?
SELECT REPLACE(REPLACE(re.body, '\r', ' '),'\n',' ')
FROM received_emails re
WHERE re.from LIKE '%@domain%';
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"> body { margin:0; color:#333; } a { text-decoration:none; color:#006699; } p { margin:0px; } img { border:0; margin:0; } /* container */ #container { width:540px; margin:0 auto; } #content { width:500px; margin:0 20px; } /* header */ #header { border-bottom:1px solid #eaeaea; padding-top:10px; padding-left:0px; padding-right:0px; padding-bottom:10px; } #title p{ font-size:20px; font-family: "arial", "sans-serif"; } #amazonLogo{ width:107px; height:31px; } /* verification msg */ #verificationMsg { padding-left:0; padding-top:9px; padding-bottom:9px; } #verificationMsg p { font-size:14px; font-family: "arial", "sans-serif"; } #verificationMsg .otp { font-size:18px; font-weight:bold; padding-top:18px; } /* account security */ #accountSecurity { padding-left:0; padding-top:9px; padding-bottom:9px; } #accountSecurity p { font-size:14px; font-family: "arial", "sans-serif"; } /* closing */ #closing { padding-left:0; padding-top:9px; padding-bottom:9px; } #closing p { font-size:14px; font-family: "arial", "sans-serif"; } </style> <title></title> </head> <body><img width="1" height="1" src="https://www.domain.url/gp/r.html?C=PEZFBQGDUNSN&M=urn:rtn:msg:20180529165336df0ef80e18cf4d10b613aec2fe80p0na&R=2ZJED16MJLBB2&T=O&U=https%3A%2F%2Fimages-na.ssl-images.com%2Fimages%2FG%2F01%2Fnav%2Ftransp.gif&H=LOVUJXIQPO7KEAPOH3USA0AXVRKA&ref_=pe_1568390_127719720_opens" /> <table align="center" cellspacing="0" id="container" cellpadding="0"> <tbody> <tr> <td> <table cellspacing="0" id="content" cellpadding="0"> <tbody> <tr> <td id="header"> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="250" id="logo"> <img src="https://images-na.com/images/G/01/x-locale/cs/te/logo._CB152417367_.png" id="logo"/> </td> <td width="250" id="title" valign="top" align="right"><p></p></td> </tr> </tbody> </table> </td> </tr> <tr> <td id="verificationMsg"> <p>Hello,<br/> some text</p> <p class="otp">197205</p> </td> </tr> <tr> <td id="accountSecurity"> <p>some more text <br/><br/>so much text <br/><br/>text text text text text </p> </td> </tr> <tr> <td id="closing"> <p>text!!! </p> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <img width="1" height="1" src="https://www.domain.url/gp/r.html?M=urn:rtn:msg:20180529165336df0ef80e18cf4d10b613aec2fe80p0na&R=2ZJED16MJLBB2&T=E&U=https%3A%2F%2Fimages.com%2Fimages%2FG%2F01%2Fnav%2Ftransp.gif&H=RQY711YLA1V0F5MUULVC8VU7ZPKA&ref_=pe_1568390_127719720_open" /></body> </html>
答案 0 :(得分:0)
经过进一步调查,能够深入研究一些其他问题,需要在其他区域中包含REPLACE()函数,以及仅粘贴为值。
这篇文章也很有帮助:Removing carriage returns in Mysql DB