INTERACT FORUM

Please login or register.

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

Author Topic: Expressions.  (Read 1942 times)

SkGe

  • Galactic Citizen
  • ****
  • Posts: 433
Expressions.
« on: September 09, 2017, 08:18:45 am »

Ok. I'm trying to find a way to get work with an expression for some of my custom field but i can't find a better solution so i came here for some help.
My custom field is a delimited list with different value, ex:
Name1 [01]; Name02 [02]; Name3 [03]; Name04 [04]; etc. Where name is different information and the digit is a value. What do i want my expression to show me is just only the value from each ex to be extrated.
Expression to shown is like these.
Ex1 get the first value. 01 (hide the name01 and []);
Ex2 get the second value: 02 (same as ex1);
Ex3, ex4 and so on get the next value.
The number of information on the field can vary so is not a fix number. Can be from 1 value from n value.
So far what method i know and try is useless. Maybe someone knew a better way to solve and can try to help.
Thanks in advice.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expressions.
« Reply #1 on: September 09, 2017, 08:56:33 am »

So do you want several expressions:  One expression to give you the numeric value of the first list element?  Then another to give you the numeric value of the second element?  Etc..

Or do you want one expression that returns a LIST with the numeric values of all of the list elements?

Maybe give an example of a real field that you are using, and then the output of the expression, or multiple expressions that you want.

Brian.
Logged

fridden

  • Recent member
  • *
  • Posts: 31
Re: Expressions.
« Reply #2 on: September 09, 2017, 12:30:22 pm »

Perhaps this might be what you are looking for?

=RegEx(ListItem([MyCustomField],2),/#\[([^]]+)\]#/,1)

This will retrieve the 2nd item and parse out the text between [ and ]

So the expression will first pick out the nth item from the list with the expression:
ListItem([MyCustomField], n)

Then it will use Regex to parse out the text between brackets from that item.

Hope this helps!

/fridden
Logged

SkGe

  • Galactic Citizen
  • ****
  • Posts: 433
Re: Expressions.
« Reply #3 on: September 09, 2017, 08:07:04 pm »

Just one expression who had the possibilities to pull that information from the field.
Lets say i have these information in the field
The 405 [90]
AV Club [91]
Drowned in Sound [90]
Entertainment Weekly [91]
Northern Transmissions [100]
Paste [91]
The Guardian [100]
The Skinny [100]
Pretty Much Amazing [100]
NME [100]
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expressions.
« Reply #4 on: September 09, 2017, 08:27:57 pm »

So if you answered Brian's question specifically..

You have a field with the contents:
The 405 [90]; AV Club [91]; Drowned in Sound [90]; Entertainment Weekly [91]; Northern Transmissions [100]; Paste [91]; The Guardian [100]; The Skinny [100]; Pretty Much Amazing [100]; NME [100]

And you want the output to be:
90; 91; 90; 91; 100; 91; 100; 100; 100; 100

Is that correct?
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

SkGe

  • Galactic Citizen
  • ****
  • Posts: 433
Re: Expressions.
« Reply #5 on: September 09, 2017, 09:01:32 pm »

That is the thing i want to get.
I did try the formula of fridden and format like these:
removeright(right(ListItem([custom field], 0),3),1) and it show me only the digit. But the problem is, when i do that, these expression will select each value as first, second and so on.
Here is an example of implementation
https://gyazo.com/d4d2e108dcbbe7d7b0c0f4917ed3963d" width="2104
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expressions.
« Reply #6 on: September 09, 2017, 09:54:48 pm »

Ah, your data is a rating from various sources, all in one list type field, and you want to break them out to make use of them.

Could you just confirm, do you want the results (all the numbers) in one List type field as per my example? Or do you want one number in each of a series of fields, as per your image?

I would bet that Brian (not me!) could write an Expression to not only pull out the numbers for you, but also save them into the correct MC field. i.e. Read both the source of the rating and the number, then write the number to the corresponding MC field. That would mean that you need a custom field for every source though, plus a catch-all field for unknown sources. But that just adds to the challenge, right?  8)

So rather than splitting the numbers out into "First Value", "Second Value". etc., write them out to the correct field as per the source.


However, that seems like a fair bit of work and processing. It may slow down MC Views quite a bit. Perhaps you should explain how you get the contents of the "AllMusic" field, which contains ratings from various source, and what your end goal is. For example, do you want to calculate an average rating across known sources, or do you really want one field per source? Are you going to apply these results to a View to select music to play?

Because there may be a better to achieve the end goal.

Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner
Pages: [1]   Go Up