ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

"Title Case" Text Expression?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tim Vaughan
"Title Case" Text Expression?
on Jul 28, 2016 at 6:44:07 pm

I'm trying to come up with an expression that can change ALL CAPS to Title Case. (Title Case In This Instance) I've been scouring the web trying to find something that would work. Thus far, only text.sourceText.toUpperCase() / text.sourceText.toLowerCase(). I imagine it's something as simple as AE's term for it, but I'm not having any luck locating it. Any help would be great.
(And before anyone suggest I just type this in as I want it, I'm making Pr Pro templates for night menus; and the end editor will simply copy/paste the info from traffic)

Thanks

Tim

--
Tim Vaughan
Production Editor and Motion Graphics, PBS Charlotte
Charlotte, NC


Return to posts index

Dan Ebberts
Re: "Title Case" Text Expression?
on Jul 28, 2016 at 6:52:38 pm

You would need to create a JavaScript title case function. Just Google "JavaScript title case" and you should find solutions at Stack Overflow.

Dan



Return to posts index

Tim Vaughan
Re: "Title Case" Text Expression?
on Jul 28, 2016 at 7:26:27 pm

Thanks Dan. I'm not great (heck, I barely know js but I'm starting...)... I've not had any luck when running the functions from stack overflow. I'm ending up with errors all over. When I try

function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}


I end up with [object layer]. (Not what I'm looking for...) To my limited knowledge, after declaring the function and adding in

text.sourceText.toTitleCase()

at the end (or toTitleCase() or variations of that, it's not working. I certainly hate to take up your time on this. I was hoping it would be rather easy....

--
Tim Vaughan
Production Editor and Motion Graphics, PBS Charlotte
Charlotte, NC


Return to posts index


Tim Vaughan
Re: "Title Case" Text Expression?
on Jul 28, 2016 at 7:29:06 pm

Wait a minute--I believe I may of stumbled upon it. :)

function toTitleCase(str)
{
return text.sourceText.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
toTitleCase()


Thanks Dan!

--
Tim Vaughan
Production Editor and Motion Graphics, PBS Charlotte
Charlotte, NC


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]