Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Title Case” Text Expression?

  • “Title Case” Text Expression?

    Posted by Tim Vaughan on July 28, 2016 at 6:44 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

    Tim Vaughan replied 9 years, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    July 28, 2016 at 6:52 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

  • Tim Vaughan

    July 28, 2016 at 7:26 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

  • Tim Vaughan

    July 28, 2016 at 7:29 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

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy