INTERACT FORUM

Please login or register.

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

Author Topic: Expression to limit number of actors? (SOLVED!)  (Read 1623 times)

sKiZo

  • World Citizen
  • ***
  • Posts: 158
Expression to limit number of actors? (SOLVED!)
« on: June 12, 2014, 09:00:04 pm »

Pretty much says it all ... MC pulls a whole lot of movie actors I don't need to see in the views and I'd like to limit what shows to the first two or three. It CAN be done in an expression column. Someone here was nice enough to provide the code some time back, but my computer crashed and I can't find the original post or retrieve the code. Seems to me it was something simple, but a review of the wiki made my head hurt.

If I need to see the entire list of actors (hey, it could happen!), they're still available in the tag list and popups.

We need a sticky with helpful expressions that us monkeys who find the editor intimidating can steal ...  ;D
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8940
Re: Expression to limit number of actors?
« Reply #1 on: June 13, 2014, 01:13:21 am »

Morning...

This will give you the first five actors from the 'Actors' filed....

Code: [Select]
listbuild(1,;,listitem([actors],0),listitem([actors],1),listitem([actors],2),listitem([actors],3),listitem([actors],4))&datatype=[list]
MC has a "Notes" feature. If you use that to store snippets, they get included in your library backups. You should always have a library backup somewhere other than your main computer, just in case. My library is eleven years old, contains around 40,000 files, and the library backup is 12.5 Mb. Stick one on a USB key drive for dire emergencies.

-marko

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to limit number of actors?
« Reply #2 on: June 13, 2014, 09:47:03 pm »

This is will give you an arbitrary limit.  This limits to 6 actors:

   Regex([actors], /#^((?:[^;]+(?:$|;\s*)){1,6})#/, 1)

Just change the 6 to whatever number you want.
Logged
The opinions I express represent my own folly.

sKiZo

  • World Citizen
  • ***
  • Posts: 158
Re: Expression to limit number of actors?
« Reply #3 on: June 13, 2014, 11:35:34 pm »

Couple ways to skin the cat, eh?

I went with the listbuild expression for two actors ...

The results ... Looks about what I had.  8)



One little fiddlybit ... how can I add a space between the first actor and the hyphen? Just adding a space in the code gets ignored. Commas don't work either as I expect that's a reserved character in the language. Some special character perhaps?

PS ... the Regex works too, but I already had the other one modified ... be interesting to see how that could be modified to skip the ";" after the last item in the list.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to limit number of actors?
« Reply #4 on: June 13, 2014, 11:38:38 pm »

To add a space or comma, escape them with a forward slash, like:

     /,
Logged
The opinions I express represent my own folly.

sKiZo

  • World Citizen
  • ***
  • Posts: 158
Re: Expression to limit number of actors? (SOLVED!)
« Reply #5 on: June 13, 2014, 11:58:19 pm »

Perfecto!



Thanks, all!
Logged
Pages: [1]   Go Up