Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Quotation Marks in a String

  • Quotation Marks in a String

    Posted by Matt Dernlan on August 19, 2013 at 11:22 pm

    Time for my first post, after years of browsing for answers. Let’s dive in.

    I’m parsing through text and turning each character into a number value on a slider (this is a small part of a very large portion of code, but that at least provides context), and I’m running into trouble matching ” and ‘ this way. I’ve tried to separate it by adding the backslash (\), but to no avail. Simply triple quoting (“””) returns an error and disables the expression. I can single double single (‘ ” ‘), which does not return an error, but also doesn’t match.

    So, does anyone know what I’m missing here? I figured those two would give me trouble as they are special characters.

    Thanks, for helping me here and many years before, even though you didn’t know it.

    textVal = thisComp.layer("Evaluate").text.sourceText;
    slideVal = effect("Chicklet_Value")("Slider");
    textLength = thisComp.layer("Type Words").text.sourceText.length;
    offsetVal = Math.floor(linear(time, 0, (timeSlider+.5), 0, textLength))

    if (offsetVal == textLength){
    slideVal = 0}
    else if (textVal == "a"){
    slideVal = 1}
    else if(textVal == "b"){
    slideVal = 2}
    else if(textVal == "c"){
    slideVal = 3}
    ...
    ...
    else if(textVal == """){
    slideVal = 47}
    else{
    slideVal = 0}

    Jeremy Dance replied 7 years, 8 months ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    August 20, 2013 at 12:30 am

    The single-double-single should work if your text actually contains the double quote character. For example, if you apply this to a slider, you’ll get 3, as expected:

    myStr = ‘abc”def’;
    myStr.indexOf(‘”‘)

    Dan

  • Matt Dernlan

    August 20, 2013 at 12:54 am

    Hmm… when I do that, I don’t receive an error, but my output is 0, which is the final “else” in my if/else statement. It’s as if it’s recognizing that it’s valid, but not returning the correct value.

    I should add that it is comparing to literally one character at a time. So it is looking at just a set of quotation marks, or just one letter, so there shouldn’t be much room for error. I’m doing this using offset and pointing a variable to a layer’s source text that is displaying just the one letter at a time.

    I could copy all the code in here, but I have lots of layers involved that depend on each other, so I thought it would be easier to understand by breaking it down to basics. If you need more information please let me know.

    Matt

  • Dan Ebberts

    August 20, 2013 at 1:49 am

    Is it possible a curly quote snuck in there? Can you paste in (here) the string you’re trying to parse?

    Dan

  • Matt Dernlan

    August 20, 2013 at 4:40 pm

    Sure, sorry about the delay.

    Also, sorry about the string….. it’s for testing purposes, and you know how you can go a little crazy 40 lines in…

    ——
    abc, 123, ba”aaaby 🙂 you and me gurl!
    ——

    Just copied and pasted that straight out of the text layer in AE.

  • Dan Ebberts

    August 20, 2013 at 5:29 pm

    That appears to be a right curly quote (”), so it won’t match a straight double quote (“).

    Dan

  • Matt Dernlan

    August 20, 2013 at 5:37 pm

    Well I am clearly out of my depth here with curly vs straight. So in my expressions, I’m using all straight quotes, but I need to match back to curly somehow? The ideal would be to be able to match to curly, since that is apparently the default, so if someone types a quote into that layer, it would match back without special formatting needed.

    Or would there be a way to automatically change the quotes to straight? I’m already changing everything to lowercase at the moment just for matching purposes.

    I’ll do a little googling but curly vs straight is never something I’ve run into.

  • Jeremy Dance

    August 29, 2018 at 11:51 pm

    For anyone finding this post much later, my solution to compare quotes in an expression was to convert it to it’s code.

    For example

    if (string.charCodeAt(0) == 8221) {
    do stuff }
    else if (string.charCodeAt(0) == 8220){
    do stuff
    {

    Those are the codes for right and left curly quotation marks in AE

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