INTERACT FORUM

Please login or register.

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

Author Topic: Weird glitch with expression for AlbumArtistSort?  (Read 1336 times)

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Weird glitch with expression for AlbumArtistSort?
« on: August 10, 2013, 12:00:09 am »

I am sure we all remember the wonderful expression that you guys helped me with to create an automatically generated "AlbumArtistSort" field.

In case not here is it:  if(regex([Album Artist], /#(The|A|El) +(.*)$#/), [R2]/, [R1], [Album Artist])

So far it has been working great!

Just came up against a weird glitch though.   For the Album Artist:  "Magna Carta"  it is giving me "Carta, a"

Strange thing is that I use the same expression to create an "Artist Sort" field and that one seems to be working correctly.

Any ideas?

(Remember I never claimed to fully understand the expression in the first place lol.)

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: Weird glitch with expression for AlbumArtistSort?
« Reply #1 on: August 10, 2013, 12:08:23 am »

Oops I lied.  it is doing the same thing for "ArtistSort" as well.  Still though the expression specifies "The, A and El"  This Artist definitely does not start with any of those.

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Weird glitch with expression for AlbumArtistSort?
« Reply #2 on: August 10, 2013, 12:37:00 am »

Make this change:

   if(regex([Album Artist], /#^(The|A|El) +(.*)$#/), [R2]/, [R1], [Album Artist])
Logged
The opinions I express represent my own folly.

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: Weird glitch with expression for AlbumArtistSort?
« Reply #3 on: August 10, 2013, 12:49:39 am »

Amazing!   1 little "^" fixes everything.   

I have no clue why but it now works.

Is there a layman's way to explain why it decided to do that in the first place with that specific group?

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Weird glitch with expression for AlbumArtistSort?
« Reply #4 on: August 10, 2013, 12:58:18 am »

Sure.  The regular expression really wants to match something.  And I had failed to force it to match only at the beginning of the line.  That's what the ^ does.

The expression looked for a "The" or "A" or "El" anywhere in the line, followed by one or more spaces, followed by anything else.  So it found the "a" at the end of "Magna", followed by the space, followed by "Carta":

   Magna Carta

Placing the anchor ^ at the beginning of the RE forces the match to start at the beginning of the string.

You might also consider if you need to enable case-sensitivity, as the default is not case sensitive in MC:

    if(regex([Album Artist], /#^(The|A|El) +(.*)$#/, 0, 1), [R2]/, [R1], [Album Artist])

We have to also supply the 0 now, which means use the test mode if regex().  The 1 is the case sensitive flag.
Logged
The opinions I express represent my own folly.

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: Weird glitch with expression for AlbumArtistSort?
« Reply #5 on: August 10, 2013, 01:03:54 am »

Cool.  I think I even understood that.

Are you missing the "^" in that last example?

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Weird glitch with expression for AlbumArtistSort?
« Reply #6 on: August 10, 2013, 01:06:34 am »

Yup, I copy/pasted from the first post instead of the corrected one.  Fixed.  Good catch.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up