From: "Byron Nash" Received: from mail-qk1-f181.google.com ([209.85.222.181] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 7440393 for AE-List@media-motion.tv; Wed, 25 Sep 2019 17:28:34 +0200 Received: by mail-qk1-f181.google.com with SMTP id h126so5591904qke.10 for ; Wed, 25 Sep 2019 08:31:48 -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=4vCzTC8Y3DjoEcsAhinOjM6qAjFGi0balqJRIJbQj/U=; b=dpi2Dx22itw7tKGh/Qfq8qXwKJTB59DZi5amItyxP3v9BJBy92qkmQ6G/6/dwYxf5h M4wK0QvuOIoTP9ll2x11BWXHVP/ykMMph7hrQI5+28Gfvudhogivn2POYlAK9e8io4xl QZp0WSwqjyrryG+WXFhg1eMg3i/GRxud6U/FlRIvKEsw09jU2TNtV1n5cM/923p1ptcH Ke1eXtv/nPZxO41jpDRnquZKIdmvmJwX8E5euv3UdQz8yooRXbDZu1nwJVL9ZnQG06PD URa8ptqw0c9DWBS2lx+CO81wAruQWmKo+/m0PwbAjPUO4KehdE77bhQ0hNN5JDlyw6jd sVeQ== 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=4vCzTC8Y3DjoEcsAhinOjM6qAjFGi0balqJRIJbQj/U=; b=YU990FfBdvIcrX6FOGfI7jWkeCNvM6gxE6DAS9RAhwgvZrFsvhyMG8fqOKDie5fPeD 9PRXGtb0hcQujKJB6KL8Mdo2OL5SDoPXG6PVsNG1DG4q6o7wPvN5guTwx6MvAagKBeMU VYvntQqwnLuXgvVj0CyFmgXup5GUyFNh/yKaHVRyXWp9BjTPd6o4RWGt5BMIzVztK4u3 oYqYt77IwH9Ses8S/t6jeRQC54aXuBjEE6DFnmvBQfMl30m06qbx0yrKEA49z+5cFfkD eiOAkkNC2114msjPxyh0mv3lzS8gousUPwKDBc6yaVLCIDk3SnmlQ1fSnStS1SRGAbCp ov2Q== X-Gm-Message-State: APjAAAWQMZ0yHfwFXSoek79bp4yKk7wjAyV555iwFPZsVaYXdJ1C5MZk MRSkUyAwt7AwMtrAi/+WbBtPTQHhHnPTfOnIw3JJTXYg X-Google-Smtp-Source: APXvYqxjP50svSe8OYBoPqC7k+AQT/hJZPA8wg/B+tii9PXcGrGi/oFvyUDSPVXNrdsdagBnU8++CgiXmfBHLQOPnCo= X-Received: by 2002:a37:a106:: with SMTP id k6mr4053596qke.158.1569425506738; Wed, 25 Sep 2019 08:31:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 25 Sep 2019 11:31:35 -0400 Message-ID: Subject: Re: [AE] Regex help on expression To: After Effects Mail List Content-Type: multipart/alternative; boundary="000000000000d4a6ac05936259a1" --000000000000d4a6ac05936259a1 Content-Type: text/plain; charset="UTF-8" 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 >>> >> --000000000000d4a6ac05936259a1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks. I see what=C2=A0you mean about arrays. Most of my = inputs will only return one result. I was hoping to get an index to find wh= ere the string starts so I can subdivide the original string. The regex tha= t you wrote is returning a -1 index no matter what it is fed. In my other t= ests with my original regex, I was getting an index. Both are using match s= o I'm not sure why it's doing that.=C2=A0

On Wed, Sep 25, 2019 at 11= :10 AM Lloyd Alvarez <AE-List= @media-motion.tv> wrote:
Hey Byron

<= div>The regex I gave you returns an array with the second item in the array= being=C2=A0the string, so first check to 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 Wed, Sep 25, 2= 019 at 8:20 AM Byron Nash <AE-List@media-motion.tv> wrote:
Thanks Lloyd, that = does return the string plus the digits. Do I not need the lookbehind to jus= t 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 Alva= rez <AE-Lis= t@media-motion.tv> wrote:
Try this:

text.sourceText= .match(/[0-9]+(ST|ND|RD|TH)/g);<= /font>
--
Cheers, Lloyd
--000000000000d4a6ac05936259a1--