Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. Find the 4th last object in this campaign

Find the 4th last object in this campaign

Scheduled Pinned Locked Moved Regular Expressions
regexhelpquestion
3 Posts 2 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Oct2022
    wrote on last edited by
    #1

    My campaigns all follow the same naming convention, i am trying to use a Regex_Extract formula in DataStudio to create a new custom dimension that only displays the 4th last element in the below campaign: "ctatext" Each element is separated by a _

    channel_product_country_medium_brand_offer_campaignname_ctatext_date_objective_0

    Closest i have gotten is:

    REGEXP_EXTRACT(Session campaign, '(.+){4}(?:[^_]+.)')

    but that only returns the 4th character in the string .. can anyone help ?

    Richard DeemingR 1 Reply Last reply
    0
    • M Michael Oct2022

      My campaigns all follow the same naming convention, i am trying to use a Regex_Extract formula in DataStudio to create a new custom dimension that only displays the 4th last element in the below campaign: "ctatext" Each element is separated by a _

      channel_product_country_medium_brand_offer_campaignname_ctatext_date_objective_0

      Closest i have gotten is:

      REGEXP_EXTRACT(Session campaign, '(.+){4}(?:[^_]+.)')

      but that only returns the 4th character in the string .. can anyone help ?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      How about something like:

      _([^_]+)(_[^_]*){3}$

      regex101: build, test, and debug regex[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      M 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        How about something like:

        _([^_]+)(_[^_]*){3}$

        regex101: build, test, and debug regex[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        M Offline
        M Offline
        Michael Oct2022
        wrote on last edited by
        #3

        Oh yes that has helped, thank you very much!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups