我希望能够在 @ 符号之后对电子邮件进行分词。
所以它看起来像下面这样
id | name | email | status
--------------------------------------
1 | Bob joe | bjoe | active
| | @gmail.com |
--------------------------------------
2 | jay c | jc@gmail.com| active
--------------------------------------
3 | David | dsmith | inactive
| Smith | @yahoo.com |
^ I want it to break the email right before the @sign
我目前的情况是这样的:
下面是相同的代码:
CSS
table{
table-layout:fixed;
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
width: 330px;
}
table td{
overflow: hidden;
}
HTML
<table class="fixed" border="1">
<col width="20px" />
<col />
<col />
<col width="70px" />
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
<th>status</th>
</tr>
<tr>
<td>1</td>
<td>Kaimana Marek</td>
<td>thisisatest@gmail.com</td>
<td>Active</td>
</tr>
<tr>
<td>2</td>
<td>Joshua Bourguignon</td>
<td>tasdflknadsfl@gmail.com</td>
<td>Inactive</td>
</tr>
<tr>
<td>3</td>
<td>Ekkehard Mehmud</td>
<td>asdflknasdc@yahoo.com</td>
<td>Active</td>
</tr>
</table>
是否可以使用自定义字符(如 @
符号)对字符串进行换行?
最佳答案
类似于 s.replace(/([^\n]{10})/g, '$1\n');
其中 {10}
是您要在其后添加分隔符的字符数。
此外,为了使其看起来一致,最好使用等宽字符,否则字符的宽度会发生很大变化。
关于jquery - 指定字符的自定义换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22971297/