Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Easy way to extract a number from a string

  • Declan Smith

    January 10, 2014 at 1:51 pm

    You can use regular expressions to extract a number from a string.

    A simple example below with return 1 or more consecutive numbers, such that if your string was “Layer123” it would return 123

    Regular expressions are very powerful to apply selection patterns. Note that the example below will return the first set of numbers it encounters.

    /d+/i.exec("layer123")

    Declan Smith
    https://www.madpanic.tv
    After Effects CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

    “it’s either binary or it’s not”

  • Paul Roper

    January 10, 2014 at 2:36 pm

    Hmmm….I can’t get that to work. I’ve tried putting that expression into a Source Text (it returns “null”) so I tried putting it in a numerical thing (rotation). It returns 0.

    Any thoughts?

    Thanks,

    Paul

  • Declan Smith

    January 10, 2014 at 2:40 pm

    Yes sorry I think the COW removed a backslash

    before the ‘d’ put a backslash

    /d+/i.exec("layer123")

    Declan Smith
    https://www.madpanic.tv
    After Effects CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

    “it’s either binary or it’s not”

  • Kevin Camp

    January 10, 2014 at 5:21 pm

    that is really cool… now i have something new to go out and learn

    thanks Declan

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy