INTERACT FORUM

Please login or register.

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

Author Topic: Removing the first word from a field  (Read 2686 times)

AndyU

  • Galactic Citizen
  • ****
  • Posts: 363
Removing the first word from a field
« on: October 10, 2011, 10:37:22 am »

Hi

I have many classical albums which I have, for historical reasons, tagged the [Name] fjeld as "Composer Work ..". For example, "Beethoven Sympohny No 3". Now I use J River and can show the Composer separately, I'd like to remove or hide the first word of each Title.

I can't find a function that will let me do that - I would like an 'INSTR' one that returned the position of the first space character in a text string so that I could then take the right hand portion of that field.

Any ideas?
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Removing the first word from a field
« Reply #1 on: October 10, 2011, 11:45:15 am »

Hi again,

Now we need the Regex() MC expression. Try something like this:
Regex([Name],/#^.*? (.*)#/,1)
Logged

AndyU

  • Galactic Citizen
  • ****
  • Posts: 363
Re: Removing the first word from a field
« Reply #2 on: October 10, 2011, 02:11:04 pm »

Thank you! I tried exactly that, and it worked. Splendid!

Can I ask you for a wee bit more ...

for many of these Classical titles, I also appended the name of the artist, eg (Mullova). Can you add to your Regex expression some magic to remove this, if it is present, so

Beethoven Piano Concerto No 3 (Brendel)

becomes

Piano Concerto No 3

Thanks again.
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Removing the first word from a field
« Reply #3 on: October 10, 2011, 04:20:14 pm »

It is late right now where I live, and I do not have any reference at hand. But you could try this:
Regex([Name],/#^.*? (.*) /(.*?/)$#/,1)

Try reverting the /( and /) if that does not work, i.e. \( and \).

MrC is really the Regex() guru here and he might work "the night shift", i.e. be in a different time zone.
Logged

AndyU

  • Galactic Citizen
  • ****
  • Posts: 363
Re: Removing the first word from a field
« Reply #4 on: October 10, 2011, 05:47:16 pm »

Brilliant! The \( and \) worked. Don't know where you are - if you're ever in Scotland I'll buy you a pint. Whoever pays you should pay you more. Thank you  :)
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Re: Removing the first word from a field
« Reply #5 on: October 10, 2011, 05:54:09 pm »

Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Removing the first word from a field
« Reply #6 on: October 11, 2011, 12:46:45 am »

Andy, whereabouts in Scotland are you? I'm in Edinburgh. Good to see a fellow Scot on the forums :)

-marko

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Removing the first word from a field
« Reply #7 on: October 11, 2011, 02:32:22 am »

Glad it worked for you.

I live in Stockholm, Sweden, so it was not _that_ late. I am just a user. I do not get paid for this. It is a hobby, like beer drinking.

And you should have a look at Marko's excellent reference page that Jim linked to. Much to learn there.
Logged

AndyU

  • Galactic Citizen
  • ****
  • Posts: 363
Re: Removing the first word from a field
« Reply #8 on: October 11, 2011, 04:07:29 am »

Marko - I'm in Glasgow, not so far ... I studied Computer Science at Edinburgh many decades ago - almost the first Computer Science course there ever was - Edinburgh Uni had it's own language called IMP and I typed my programs onto punched cards. In those days I'd have read your guide, stayed up all night, taught myself regular expressions, I dare say written my own parser and got it all to work .. now, one of the small advantages of being (a lot) older is that I have no shame in asking for help. Thanks again guys.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Re: Removing the first word from a field
« Reply #9 on: October 11, 2011, 06:37:49 am »

Andy, whereabouts in Scotland are you? I'm in Edinburgh. Good to see a fellow Scot on the forums :)

-marko
I believe weehappypixie is also a Scot.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Re: Removing the first word from a field
« Reply #10 on: October 11, 2011, 06:41:32 am »

... have a look at Marko's excellent reference page that Jim linked to. Much to learn there.
That's a combined work of both Marko and MrC.  It's an amazing work.
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Removing the first word from a field
« Reply #11 on: October 11, 2011, 09:52:05 am »

That's a combined work of both Marko and MrC.  It's an amazing work.

Of course. Sorry about that, MrC.
Logged

harrydr

  • Junior Woodchuck
  • **
  • Posts: 54
Re: Removing the first word from a field
« Reply #12 on: October 11, 2011, 05:38:36 pm »

Simple MC user from the beginning, love it.
Thanks for the link JimH a lot to learn. We drink Rum And Coca Cola in the Dominican Republic.
Logged
Pages: [1]   Go Up