FORUMS: list search recent posts

Quotation Marks in a String

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matt Dernlan
Quotation Marks in a String
on Aug 19, 2013 at 11:22:39 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}


Return to posts index

Dan Ebberts
Re: Quotation Marks in a String
on Aug 20, 2013 at 12:30:50 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



Return to posts index

Matt Dernlan
Re: Quotation Marks in a String
on Aug 20, 2013 at 12:54:25 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


Return to posts index


Dan Ebberts
Re: Quotation Marks in a String
on Aug 20, 2013 at 1:49:10 am

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

Dan



Return to posts index

Matt Dernlan
Re: Quotation Marks in a String
on Aug 20, 2013 at 4:40:24 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.


Return to posts index

Dan Ebberts
Re: Quotation Marks in a String
on Aug 20, 2013 at 5:29:24 pm

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

Dan



Return to posts index


Matt Dernlan
Re: Quotation Marks in a String
on Aug 20, 2013 at 5:37:52 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.


Return to posts index

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