I want 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.
Use the replace() method to replace spaces with dashes in a string, e.g. str. replace(/\s+/g, '-') . The replace method will return a new string, where each space is replaced by a dash.
You can also click the Home tab in the Ribbon and select Replace in the Find & Select group. In the Find what box, type a space. In the Replace with box, type an underscore, dash, or other value. If you want to replace the space with nothing, leave the box blank.
sub('\s+', '-', "How are you"); # To replace any sequence of 1 or more "space" by one hyphen: >>> re. sub(' +', '-', "How are you");
var new_string = string. replace(/-|\s/g,""); a|b will match either a or b , so this matches both hyphens and whitespace.
value = value.toLowerCase().replace(/ /g,'-');
See also:
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,"-")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With