Closed Thread Icon

Topic awaiting preservation: capitalise the first letter after a hyphen? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8854" title="Pages that link to Topic awaiting preservation: capitalise the first letter after a hyphen? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: capitalise the first letter after a hyphen? <span class="small">(Page 1 of 1)</span>\

 
smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 09-09-2003 22:10

Hi,

As this forum is testament to, I have been playing around with css styles and javascript. I'm now looking for a teeny weeny bit of code that can take a string like:

FONT-WEIGHT : BOLD;

And turn it into:

fontWeight : bold;

I figure that is could be done by simply 'toLowerCase()'ing the string, then using a regular expression to 'toUpperCase()' the first letter after the '-' , followed by '.replace('-','')' or a '.split('-').join('')' to remove the unwanted hyphen.

Ideally all of that would be done in one go in no more than one line of js. I can't figure it out tho

I would appreciate anybody's help with this possibly simple task.

Thanks again,

Jon

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 09-10-2003 07:22

Here's your one-liner...

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- ;

// Written by mr.maX, http://www.maxempire.com/
function parse(what)
{
&nbsp;&nbsp;&nbsp;&nbsp;return what.toLowerCase().replace(/\-(\S{1})/,function(m,n,o,s){return n.toUpperCase()});
}

// Test...
document.write(parse("FONT-WEIGHT : BOLD;"));

// -->
</SCRIPT>


smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 09-11-2003 00:23

Perfect

Thanks bud

[EDIT]

P.S. How is your html editor coming along? I tried the old (current) version the other day and was pretty impressed. I like the way the syntax highlighting is similar to that of Dreamweaver (my main wysiwyg editor). Dreamweaver's editor is good but when you only want to make quick changes or code only changes it gets a bit irritating opening Dreamweaver.

Will the new version still come out next month? One thing I would really like to see is a script 'beautifying' function for javascript and php - I'm not a good coder and my code tends to get a bit all over the place the more I edit it and chop it up.

Also just a note - the new Dreamweaver MX 2004 is priddy, functionality-wise I have seen no grea improvements, just a few useability tweaks and some niggles got rid of. Flash MX 2004 on the other hand is really sweet - my current favourite aspect being the alias text option - one button and all your text will be as crisp as a cool lager with curry, and you don't even have to put it on a whole pixel!

[This message has been edited by smonkey (edited 09-11-2003).]

« BackwardsOnwards »

Show Forum Drop Down Menu