Forum Replies Created

Page 2 of 2
  • Excellent that worked, thanks again Declan!

  • Hey Declan,

    Okay cool, thank you! I seem to be having issues with counting \ and “, though both are escaped out.

    Entering a \ is causing after effects to disable the expression and give an “Unterminated string constant” error and ” just isn’t counting, any thoughts?

    Thanks again!

    var i = (firstline.match(/f|t|\/|\\|\"/g)||[]).length;

  • Perfect, that solved it! Thank you so much Declan!

  • Hey Declan,

    Your right that one does seem to be okay on its own, specifically I’m running into it when I’m trying to count punctuation like in the code below, that seems to be returning total string length. I’m guessing its because AE is seeing the “.” and “!” as part of the expression as opposed to string values?

    Any thoughts on how to address this?

    b = ((firstline.match(/.|!/g)||[]).length)

  • I may have answered my own question, putting what I did here incase anyone else has a similar question in the future.

    I used indexOf to check for the desired input characters then used an if/else statement to either count the number of desired characters or set the variable to 0.

    This appears to be working, if anyone else has a more elegant solution let me know.

    Thanks!

    //defines the variables
    txt = thisComp.layer("Overlay TXT Here").text.sourceText;

    //statement body
    if (txt.indexOf("e"|"f"))
    a = (txt.match(/e|f/g)||[]).length
    else
    a=0;

    //print total value
    a

  • Bryce Poole

    August 11, 2014 at 11:44 pm in reply to: Create Line Break After X Number of Characters

    Dan, this is excellent, this code makes it so much cleaner than what I had, I really appreciate the help. Thank you very much!!

  • Bryce Poole

    August 9, 2014 at 12:57 am in reply to: Create Line Break After X Number of Characters

    Hey Dan,

    Preventing it from splitting in the middle of a word is actually something I’d really like it if the code could handle, I was doing some test this afternoon and was just offsetting any breaks mid word with extra spaces before to it down to the next line, but thats really clunky…

    Do you have any thoughts on a more elegant way to write this?

    Thank you so much!
    — Bryce P.

  • Bryce Poole

    August 8, 2014 at 7:47 pm in reply to: Create Line Break After X Number of Characters

    Okay, this appears to have solved the issue, incase anyone else is trying to do something similar.

    txt = value
    if (thisComp.layer("Overlay TXT Here").text.sourceText.length >= 61) {
    txt.substring(0,61) + "\r" + txt.substring(62,999);
    } else {
    txt
    }

Page 2 of 2

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