如题.
2.代码.
3.注意. ^\n代表你要插入的字符,这个是"不包含换行符"的意思 .
- <script type="text/javascript">
- var name="jjjjjj哈哈jjjjjjjjjjjjjddddddddddddddddddddkkkkkkkkkkkkkkkkkk";
- name=name.replace(/([^\n]{20})/g,"$1\n");
- alert(name);
- </script>
3.注意. ^\n代表你要插入的字符,这个是"不包含换行符"的意思 .
- <script type="text/javascript">
- var name="jjjjjj哈哈jjjjjjjjjjjjjddddddddddddddddddddkkkkkkkkkkkkkkkkkk";
- name=name.replace(/([^\n]{20})/g,"$1\n");
- alert(name);
- </script>