views:

124

answers:

3

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.

+1  A: 

The tr command can do this:

$ tr 'A-Z ' 'a-z-'
CUSTOMER FAQS
customer-faqs
HOW wE can HELP
how-we-can-help
Greg Hewgill
is this javascript code? how can i use it
metal-gear-solid
`tr` is a Unix command line command. You asked for an "online or offline" tool, so `tr` is offline.
Greg Hewgill
I'm using Windows XP and i have dreamweaver installed , now pls tell me how can i use your code. i've this also http://www.waterproof.fr/products/RegExpEditor/
metal-gear-solid
If you're running Windows and you want to use `tr`, install Cygwin: http://cygwin.com
Greg Hewgill
I think installing Cygwin is a bit of overkill for this requirement.
APC
+3  A: 
YOURTEXT.toLowerCase().replace(/ /g,"-")
S.Mark
what is this code. how can i do. pls expain me.
metal-gear-solid
Ah you beat me to it!
T. Stone
Ah no problem, I think you did that, I just got a claim :P
S.Mark
+4  A: 
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:


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>
T. Stone
can i give me explanation how can i use this code with any online or offline tool
metal-gear-solid
+1 for good explanations and more helpful links
S.Mark
@T.stone thx for info I've seen links but still idon;t know how to use. can u give me any link step by step link. I don't know javascript hardcore programming and regex
metal-gear-solid
@T. Stone: I tried but it add - at end also
metal-gear-solid
See example here http://jsbin.com/eweci
metal-gear-solid
T. Stone