From: "Byron Nash" Received: from mail-qk1-f178.google.com ([209.85.222.178] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 7440399 for AE-List@media-motion.tv; Wed, 25 Sep 2019 18:06:20 +0200 Received: by mail-qk1-f178.google.com with SMTP id y189so5768451qkc.3 for ; Wed, 25 Sep 2019 09:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=LeimLtnaXu7lsqTc/H8Otp0p2VB6NpUZDCpZk7RqyxY=; b=E6gDBpF7w5KQKNP/jeILcMw7OFGlj+Y/cBTZX5DixSdpHY+UCOv+HqUpPST4SNvQet Sdrk7mcUvEB576ylNm5XyT5wIGnHuLCz9iuElLbgnhmOnEvVkTRXvp7csXJMyd71Pg2l waj7mWQ0I2SxiW7ltpFWzmp/3uwiIojlyMIeY2tFC/fc898lRBTWcGOODt7kY1DG1hXL 6gXzGEGZATAckcXa+kLRo0sSU7V9IpUzGsdqAtq36cArWxV5Yf1O6J5hTqs5Cn4KZQYI +x1YoOUggrFGWCnKttqZjyn70xfin5d8PiXxpnuBDQd2u2K3zinWSZvab/hmf8T8fvZo uWeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=LeimLtnaXu7lsqTc/H8Otp0p2VB6NpUZDCpZk7RqyxY=; b=LoPJiMlKELouVK0791TWpUQLc0pKBPGj4MrDgWR6ft1VFqVpGDskyzV67ehWpudd5O +igCrvfjNhyqlvz4nVPzPFY2bgYmaH9Mw89Vn7IlKyydO3Ya8DXRU8sxpXzFPUSXPYaK IhgdNgoFlk4XKT8rirWPfR6Md4QvaMqVkaL+Y4q7DULBs2p+KwROLF5fyEWx+F8IjwBB dnn5tHcG3qcf8CyIozJ/tPs2WHQiVEekA8AVwOcw6YukIdHZCs7O8I9rp8nFYDMuI/Nn hEFhQguk3tZtD8qFJnvlRXUCnQvXNSl+HBax2EI0ZJK59BAdM/pbLp89M9deqpzp37/e aBKQ== X-Gm-Message-State: APjAAAVFQvmIT0ss+k/kFF4T9bbnGrULaEYRqHqpKIZdNcvhctKTHskQ Dfyna1CojccISR6Ye2F/lU0w5H08DpXMg6e8QT0Bps4K X-Google-Smtp-Source: APXvYqyNdqDW+6Eg6AfRFev/juDkOfeIQVL4pUdh5+VH8WERU1k+biHM3KXxh6bhef6kayYXFJfzyQ/cg0xp86YzkzI= X-Received: by 2002:a37:684:: with SMTP id 126mr4361680qkg.416.1569427772190; Wed, 25 Sep 2019 09:09:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 25 Sep 2019 12:09:20 -0400 Message-ID: Subject: Re: [AE] Regex help on expression To: After Effects Mail List Content-Type: multipart/alternative; boundary="000000000000dcb3c1059362e0fb" --000000000000dcb3c1059362e0fb Content-Type: text/plain; charset="UTF-8" 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? On Wed, Sep 25, 2019 at 12:03 PM Lloyd Alvarez wrote: > > > 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;* > *}* > > > > Cheers, > Lloyd > > > On Wed, Sep 25, 2019 at 11:32 AM Byron Nash > wrote: > >> 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. >> >> On Wed, Sep 25, 2019 at 11:10 AM Lloyd Alvarez >> wrote: >> >>> 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;* >>> >>> Cheers, >>> Lloyd >>> aescripts + aeplugins >>> >>> >>> On Wed, Sep 25, 2019 at 8:20 AM Byron Nash >>> wrote: >>> >>>> 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! >>>> >>>> On Tue, Sep 24, 2019 at 7:07 PM Lloyd Alvarez >>>> wrote: >>>> >>>>> Try this: >>>>> >>>>> *text.sourceText.match(/*[0-9]+(ST|ND|RD|TH)*/g);* >>>>> -- >>>>> Cheers, Lloyd >>>>> >>>> --000000000000dcb3c1059362e0fb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
OK, I'll give that a try. Maybe I'm doing it all w= rong. Basically, I need to chop up a text line into component parts for a M= OGRT.=C2=A0

SUNDAY, AUGUST 31ST | 10PM ET

In this example, our look requires the "ST" and the "PM= ET" to be in a different=C2=A0font weight than the other characters. = So, I'm splitting up the input text into separate layers. How could I u= se match more effectively here?

On Wed, Sep 25, 2019 at 12:03 P= M Lloyd Alvarez <AE-List@medi= a-motion.tv> wrote:

> I was hoping to get an inde= x 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 anyt= hing you need,=C2=A0 but if you need the index then use exec instead of mat= ch:

var match =3D (/[0-9]+(= ST|ND|RD|TH)/g).exec(text.sourceText);
if (match=C2=A0!=3Dnull){
=C2=A0 =C2=A0 match.index +=C2=A0match[0].length;
}


Cheers,
Lloy= d


On Wed, Sep 25, 2019 at 11:32 AM Byron N= ash <AE-Lis= t@media-motion.tv> wrote:
Thanks. I see what=C2=A0you mean about ar= rays. 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 stri= ng. The regex that you wrote is returning a -1 index no matter what it is f= ed. 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.=C2=A0
On Wed, S= ep 25, 2019 at 11:10 AM Lloyd Alvarez <AE-List@media-motion.tv> wrote:
Hey Byron

The regex I gave you returns an arra= y with the second item in the array being=C2=A0the string, so first check t= o make sure the return is not null and then grab the second item:

var theTextArray =3D=C2=A0text.= sourceText.match(/[0-9]+(ST|ND|RD|TH)/g);
var theText =3D (theTextArray !=3D null && = theTextArray.length >=3D2) ?=C2=A0theTextArray[1] : "";
theText;

Cheers,
Lloyd
aescripts + aeplugins


On Tue, = Sep 24, 2019 at 7:07 PM Lloyd Alvarez <AE-List@media-motion.tv> wrote:
T= ry this:

text.sourceText.match(/[0-9]+(ST|ND|RD|TH)/g);
--
C= heers, Lloyd
--000000000000dcb3c1059362e0fb--