INTERACT FORUM

Please login or register.

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

Author Topic: Regex request  (Read 887 times)

Fred1

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 491
  • Change this by choosing profile
Regex request
« on: April 03, 2013, 08:33:54 am »

Hi,

i have a perhaps trivial question:

There is a field called Artist-Name which contains the Artist and Name of a song, separated by a „ | “, for example:

- Artist-Name -----------------------------------
Jean Michel Jarre | L'ouverture (Overture)
Jean Michel Jarre | Arpégiateur (Arpegiator)
Jean Michel Jarre | Equinoxe, Pt. 4


I would like to fill my Artist and Name fields with the contents of the splitted Artist-Name field like this.

- Artist --------------   -Name ----------------------
Jean Michel Jarre        L'ouverture (Overture)
Jean Michel Jarre        Arpégiateur (Arpegiator)
Jean Michel Jarre        Equinoxe, Pt. 4


Can i do this with a Regex? If yes, how?

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Regex request
« Reply #1 on: April 03, 2013, 11:59:30 am »

You can use Regex(), but you might also find it easier to use ListItem():

Artist:
   =ListItem([Artist-Name], 0, / |/ )

Name:
   =ListItem([Artist-Name], 1, / |/ )

The first is used to assign Artist, the second to assign to Name.

Using Regex(), which is wrapped by an If(), you can safely use it against even an Artist-Name without a " | " separator:

Artist:
   =if(regex([Artist-Name], /#(.*) \| (.*)#/), [R1], [Artist-Name])

Name:
   =if(regex([Artist-Name], /#(.*) \| (.*)#/), [R2], [Artist-Name])
Logged
The opinions I express represent my own folly.

Fred1

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 491
  • Change this by choosing profile
Re: Regex request
« Reply #2 on: April 03, 2013, 12:34:34 pm »

Thank you, MrC!

I will try the different methods this evening.
Logged
Pages: [1]   Go Up