|
|
I see, well in that case then yes, having the index and using text animators might be the best solution :)
OK, I'll give that a try. Maybe I'm doing it all wrong. Basically, I need to chop up a text line into component parts for a MOGRT.
SUNDAY, AUGUST 31ST | 10PM ET
In this example, our look requires the "ST" and the "PM ET" to be in a different font weight than the other characters. So, I'm splitting up the input text into separate layers. How could I use match more effectively here?
> I was hoping to get an index to find where the string starts so I can subdivide the original string
Why do 2 steps when the regex should be able to match anything you need, but if you need the index then use exec instead of match:
var match = (/[0-9]+(ST|ND|RD|TH)/g).exec(text.sourceText); if (match !=null){ match.index + match[0].length;}
Thanks. I see what you mean about arrays. Most of my inputs will only return one result. I was hoping to get an index to find where the string starts so I can subdivide the original string. The regex that you wrote is returning a -1 index no matter what it is fed. In my other tests with my original regex, I was getting an index. Both are using match so I'm not sure why it's doing that.
Hey Byron
The regex I gave you returns an array with the second item in the array being the string, so first check to make sure the return is not null and then grab the second item:
var theTextArray = text.sourceText.match(/[0-9]+(ST|ND|RD|TH)/g); var theText = (theTextArray != null && theTextArray.length >=2) ? theTextArray[1] : ""; theText;
Thanks Lloyd, that does return the string plus the digits. Do I not need the lookbehind to just return the string? I tried adding the lookbehind back in but it doesn't work.
Nathan, I didn't run across that site but I will check it out, thanks!
text.sourceText.match(/[0-9]+(ST|ND|RD|TH)/g);
--
Cheers,
Lloyd
|
|