INTERACT FORUM

Please login or register.

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

Author Topic: Help with regex to sort out name - artist in name  (Read 1743 times)

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Help with regex to sort out name - artist in name
« on: December 01, 2012, 07:09:50 am »

It really annoys me that I can't seem to get the hang of using regex when it's so useful - I have read the doc!. I have a set of names that end with the artist at the end after a -.   So I should need a capture group for the - space and then all characters after that to the end of the string will go into artist.   Can someone help with the regedit needed.

Peter Rowan
Logged

Boltron

  • Junior Woodchuck
  • **
  • Posts: 94
Re: Help with regedit to sort out name - artist in name
« Reply #1 on: December 01, 2012, 08:06:59 am »

You can try these:

Will take the Filename and return everything after a -. It will include the -.
Regex([Filename (name)], /#(-.*)#/, 1)

This will remove the - at the beginning.
Regex([Filename (name)], /#(-.*)#/, -1)RemoveLeft([R1],1)

You can substitute Filename [Filename (name)] for [Artist] if you want to scan the artist name instead of the filename.

The basic use for regex is Regex([<WhatEverField>], /#(  <MatchSyntax>  )#/, 1)

Hope this helps.
Logged
For every expert, there is an equal and opposite expert.

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Re: Help with regex to sort out name - artist in name
« Reply #2 on: December 01, 2012, 10:18:19 am »

Worked perfectly
=if(Regex([Name], /#(-.*)#/, -1)RemoveLeft([R1],2),[Author]). Thank you.

Peter Rowan
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Help with regedit to sort out name - artist in name
« Reply #3 on: December 01, 2012, 12:00:07 pm »

Peter,

Search the forum here for regex and you'll find some examples and explanations.  Search regex, and not regedit. :-)

If you have strings of the form:

   stuff - artist

then use the following:

   Regex([Name], /#- (.+)$#/, 1)

There is no need to use RemoveLeft().  By adjusting the capture, you'll get only the portion you care about.  A point of clarification - you only need to group, both capturing and cloistering (the non-capturing form), when you want to remember a sequence, or apply other operations to a particular sequence.
Logged
The opinions I express represent my own folly.

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Re: Help with regex to sort out name - artist in name
« Reply #4 on: December 02, 2012, 05:24:20 am »

Peter,

Search the forum here for regex and you'll find some examples and explanations.  Search regex, and not regedit. :-)

If you have strings of the form:

   stuff - artist

then use the following:

   Regex([Name], /#- (.+)$#/, 1)

There is no need to use RemoveLeft().  By adjusting the capture, you'll get only the portion you care about.  A point of clarification - you only need to group, both capturing and cloistering (the non-capturing form), when you want to remember a sequence, or apply other operations to a particular sequence.

What does the (.+) do and is the fact that you have a space after the - mean it is looking for - followed by space.

Peter Rowan
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Help with regex to sort out name - artist in name
« Reply #5 on: December 02, 2012, 07:41:31 am »

The parens remember what is matched for later use, the dot means any character, and the + is a quantifier that means 1 or more of the previous thing.

You have it exactly right — the dash space are liberal characters that must be matched.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up