Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Inserting space before a capital letter

  • Inserting space before a capital letter

    Posted by Griffin Englander on March 19, 2018 at 2:36 am

    Hey all,

    Bugger all expression knowledge relative to the rest of this forum, but here’s my question.

    I’m using the below expression to deliver the comp name from “JobNumber_CompName”

    I’m just wondering if it’s possible for an expression to see the capital letter (Specifically any after the C) and insert a space beforehand?

    I know I could just add the space in the comp name, but for output purpose, I’d rather not.

    Thanks in advance!

    thisComp.name.split("_")[1]

    Griffin Englander replied 8 years, 1 month ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    March 19, 2018 at 3:00 am

    I can’t tell if this is what you’re looking for, but maybe:

    ” ” + thisComp.name.split(“_”)[1];

    Dan

  • Griffin Englander

    March 19, 2018 at 4:11 am

    Thanks for the reply Dan,

    Sorry I shouldv’e been more clear. My end goal is for the text to show “Comp Name” or whatever it would be named.

    Basically looking for a Capital and inserting a space between. Ie. JobNumber32A_JobCalledBob, would return “Job Called Bob”

    This doesn’t feel very possible but worth a shot.

    Cheers

  • Griffin Englander

    March 19, 2018 at 4:14 am

    Okay, little updated.

    I’ve found I can accomplish it, if I separate the words by another “_” and use this expression

    thisComp.name.split(“_”)[1]+(” “)+thisComp.name.split(“_”)[2]

    Is there a way for the expression to look for the number of underscores, and array them as such?

  • Kevin Camp

    March 19, 2018 at 8:01 pm

    in regards to splitting based off capital letters, i found this thread on stack overflow:
    https://stackoverflow.com/questions/7888238/javascript-split-string-on-uppercase-characters

    and was able to make it work in AE with this expression:

    myComp = thisComp.name.split("_")[1] ;
    myComp.match( /[A-Z][a-z]+|[0-9]+/g ).join(" ") ;

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Griffin Englander

    March 19, 2018 at 11:06 pm

    You’re a legend Kevin. Works a charm.

    Thank you!

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