Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <textarea id="input_field" cols="9" rows="2"></textarea>
- <pre id="result">
- </pre>
- <script>
- function wordwrap() {
- var pre = document.getElementById("result");
- var textarea = document.getElementById("input_field");
- if (!textarea.value || textarea.value == '') {
- pre.innerHTML = '';
- } else {
- var regex = '.{1,' + textarea.cols + '}(\\s|$)' + '|.{' + textarea.cols + '}|.+$';
- pre.innerHTML = textarea.value.match( RegExp(regex, 'g') ).join( '\n' );
- }
- }
- setInterval("wordwrap()", 100);
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment