INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression Help - Extracting data between variables that contain a value  (Read 621 times)

mvandyke

  • World Citizen
  • ***
  • Posts: 159

I've worked with expressions (to some degree) and have completed some work but not getting exactly what I'm trying to complete.

I'm trying to extract data between •    • that meet contains a specific string.   

For example I would like to extract data that contains the variable "2003" but no other data for a field (Album Awards) that contains:

Q Magazine: 20 Loudest Albums of All Time (17)  •  Rolling Stone: 500 Greatest Albums of All Time: 2003 edition (15)  •  Rolling Stone: 500 Greatest Albums of All Time: 2012 edition (15)  •  Rolling Stone: 500 Greatest Albums of All Time: 2020 edition (30)  •  The Guardian 100 Best Albums Ever (30)  •  Uncut: The 100 Greatest Debut Albums (2006) (3)


I would like the expression to display    "Rolling Stone: 500 Greatest Albums of All Time: 2003 edition (15)"    but nothing else, so that I can then copy that text string to another field (RS Top 500 Albums 2003)

Any assistance would be appreciated.  I'm sure that it's a regex command but not having any luck (that one seems to be more difficult for me).


Thanks
Matt
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2620
Re: Expression Help - Extracting data between variables that contain a value
« Reply #1 on: October 29, 2022, 12:20:15 pm »

Split on the dots to create a list, filter for items containing '2003', return only the first of those items:
Code: [Select]
listitem(listgrep(replace([Album Awards],•,;),2003,0),0)
If it's not always 2003 then it needs some changes.
Logged

mvandyke

  • World Citizen
  • ***
  • Posts: 159
Re: Expression Help - Extracting data between variables that contain a value
« Reply #2 on: October 29, 2022, 01:50:53 pm »

It worked perfectly.

Thanks so much!!!!   Your expertise saved me much time of guessing and experimenting!

Matt

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression Help - Extracting data between variables that contain a value
« Reply #3 on: October 30, 2022, 09:49:23 am »

ZYBex is becoming the new defacto master of MC Expressions...

Nice job.  :)

Brian.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2620
Re: Expression Help - Extracting data between variables that contain a value
« Reply #4 on: October 30, 2022, 10:46:53 am »

What do you mean "becoming" ? ;D
Logged
Pages: [1]   Go Up