ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Inserting space before a capital letter

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Griffin Englander
Inserting space before a capital letter
on Mar 19, 2018 at 2:36:58 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]


Return to posts index

Dan Ebberts
Re: Inserting space before a capital letter
on Mar 19, 2018 at 3:00:12 am

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

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

Dan



Return to posts index

Griffin Englander
Re: Inserting space before a capital letter
on Mar 19, 2018 at 4:11:12 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


Return to posts index


Griffin Englander
Re: Inserting space before a capital letter
on Mar 19, 2018 at 4:14:40 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?


Return to posts index

Kevin Camp
Re: Inserting space before a capital letter
on Mar 19, 2018 at 8:01:15 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-uppe...

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


Return to posts index

Griffin Englander
Re: Inserting space before a capital letter
on Mar 19, 2018 at 11:06:44 pm

You're a legend Kevin. Works a charm.

Thank you!


Return to posts index

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