From: "Lloyd Alvarez" Received: from c147c-aesc.jetrails.io ([69.27.38.85] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 7440395 for AE-List@media-motion.tv; Wed, 25 Sep 2019 17:59:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aescripts.com; s=default; h=Content-Type:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JT6bKGzMshYX7KCXUREbqU/My5wzjXU4fV8qlPcttKo=; b=nrdFfemA+4avGZ/GnxfiAcbdj FHEZXMTIxKY4ygN99oUGY55hqM52B2wAVmEuS0q8ZKybysxXj3ucrhsIgWL8EzrMO4ZzKD2669wnl nppdmJDeO5Jpu1B5OPWu0zBtKjc9Qt2qA1XclqpCG4JkvmWKecGAZQSp87SU0GQSEm6IIpgyhrZF4 qzvJ0QmB5hKNEvWi4Lbr889CdUsYnYO9U2nUV2fp/vKs+8p2XQn66M5mu29jZRUIo9K5QgdwHrva8 TB8DYzA49pVBmDpCBnlXDB5xnjLXiXzg1z2mppoBfXx3bSU5xkJ515SWcHxMf67JfHVrZE+YOjpY4 PTpM4lYHw==; Received: from mail-vs1-f46.google.com ([209.85.217.46]:39995) by c147c-aesc.jetrails.io with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1iD9kh-0001PS-Us for AE-List@media-motion.tv; Wed, 25 Sep 2019 16:02:52 +0000 Received: by mail-vs1-f46.google.com with SMTP id v10so4180460vsc.7 for ; Wed, 25 Sep 2019 09:02:51 -0700 (PDT) X-Gm-Message-State: APjAAAW8MTD2/ow7pm1vFf+lDZQ1M0WIkABFqo36Q+/OWYyoUXoxPXR3 3V+mWf6ezlC0yuXq6fjOpjSSgNo999EojYIsCiA= X-Google-Smtp-Source: APXvYqzayPCN11vWCyZVoJKC68WtwAdQ9z5VlRGPq4E9sJfuRM1mQNonCAmxvsdsDde9GFVhMuxhkufTYDxa99eY77o= X-Received: by 2002:a67:6542:: with SMTP id z63mr5483046vsb.143.1569427371521; Wed, 25 Sep 2019 09:02:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 25 Sep 2019 12:02:15 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [AE] Regex help on expression To: After Effects Mail List Content-Type: multipart/alternative; boundary="000000000000fafc54059362c825" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - c147c-aesc.jetrails.io X-AntiAbuse: Original Domain - media-motion.tv X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - aescripts.com X-Get-Message-Sender-Via: c147c-aesc.jetrails.io: authenticated_id: smtp@aescripts.com X-Authenticated-Sender: c147c-aesc.jetrails.io: smtp@aescripts.com X-Source: X-Source-Args: X-Source-Dir: --000000000000fafc54059362c825 Content-Type: text/plain; charset="UTF-8" > 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 >>>> >>> --000000000000fafc54059362c825 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

> I was hoping to get an index to find w= here the string starts so I can subdivide the original string

Why do 2 steps when the regex should be able to match anything you ne= ed,=C2=A0 but if you need the index then use exec instead of match:

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


Cheers,
Lloyd

=

On Wed, Sep 25, 2019 at 11:32 AM Byron Nash <AE-List@media-motion.tv> wrote:
Thanks. I see= what=C2=A0you mean about arrays. Most of my inputs will only return one re= sult. 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.=C2=A0

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

The rege= x I gave you returns an array with the second item in the array being=C2=A0= the string, so first check to make sure the return is not null and then gra= b the second item:

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

<= div dir=3D"ltr">
Cheers,
Lloyd
a= escripts + aeplugins


On Wed, Sep 25, 2019 at 8:20 A= M Byron Nash <AE-List@media-motion.tv> wrote:
Thanks Lloyd, that does return t= he 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 i= t out, thanks!

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

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