Created
April 12, 2015 02:38
-
-
Save answerquest/273360c7098428f2449a to your computer and use it in GitHub Desktop.
Convenient single page to Zap extra spaces, commas, newlines, tabs in the text in a textarea (paragraph textbox) through different buttons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<head><title>Zap extra spaces, commas etc</title> | |
<style> | |
input { | |
width: 15em; height: 3em; | |
} | |
</style> | |
<body> | |
<form id="form1"> | |
<table> | |
<tr width="100%"> | |
<td> | |
<b>Input</b> text-box<br/> | |
<textarea name="input" id="box" cols="100" rows="30" ></textarea> <br> | |
<!-- onFocus="this.select();"--> | |
</td> | |
<td> | |
<input type="button" value="Zap all commas" accesskey="c" title="shortcut shift+alt+c" onClick="var THIS = document.getElementById('box').value; document.getElementById('box').value = THIS.split(',').join('');"> | |
<br><br><br> | |
<input type="button" value="Zap all extra spaces" onClick="var THIS = document.getElementById('box').value; document.getElementById('box').value = THIS.replace(/\ {2,}/g, ' ');"> | |
<br><br><br> | |
<input type="button" value="Zap all tabs" onClick="var THIS = document.getElementById('box').value; document.getElementById('box').value = THIS.split('\t').join(' ');"> | |
<br><br><br> | |
<input type="button" value="Zap all newlines" onClick="var THIS = document.getElementById('box').value; document.getElementById('box').value = THIS.split('\n').join(' ');"> | |
<br><br><br> | |
<input type="button" value="Zap all spaces, tabs, newlines" onClick="var THIS = document.getElementById('box').value; document.getElementById('box').value = THIS.replace(/\s{2,}/g, ' ').split('\t').join(' ');"> | |
</td> | |
</tr> | |
</table> | |
</form> | |
<br><br> | |
<a href="http://stackoverflow.com/questions/1981349/regex-to-replace-multiple-spaces-with-a-single-space">Got from stackoverflow</a>, and elsewhere. | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment