I w开发者_JAVA技巧ant to convert good bunch of url text.
from
CUSTOMER FAQS
HOW wE can HELP
PLANNING YOUR BUDGET
CUSTOMER CASE STUDIES
TENANT DISPUTES
EXIT STRATEGIES
USEFUL dOCUMENTS
USEFUL lINKS
to
customer-faqs
how-we-can-help
planning-your-budget
customer-case-studies
tenant-disputes
exit-strategies
useful-documents
useful-links
Is there any online or offline tool which can do this?
I want to do both thing at once.
value = value.toLowerCase().replace(/ /g,'-');
- toLowerCase -> convert this string to all lower case
- replace(/ /g,'-') -> Globally replace (/g) all spaces (/ /) with the string -
See also:
- Convert JavaScript String to be all lower case?
- Regex for replacing a single-quote with two single-quotes
If you just want to have this functionality and use it locally in your browser, you can make yourself a simple html page and save it to your desktop as convert.html (or whatever). However if you're going to go that far, I'd just use a shell script/command as one of the other answers posted.
<html>
<body>
<h2>Input</h2>
<textarea id="input"></textarea>
<button onClick="doConvert()">Convert</button>
<hr/>
<h2>Output</h2>
<textarea id="output"></textarea>
<script type="text/javascript">
function doConvert() {
var value = document.getElementById('input').value;
var newValue = value.toLowerCase().replace(/ /g,'-');
document.getElementById('output').value = newValue;
}
</script>
</body>
</html>
YOURTEXT.toLowerCase().replace(/ /g,"-")
The tr
command can do this:
$ tr 'A-Z ' 'a-z-'
CUSTOMER FAQS
customer-faqs
HOW wE can HELP
how-we-can-help
精彩评论