INTERACT FORUM

Please login or register.

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

Author Topic: Regex  (Read 495 times)

sufokeet

  • Regular Member
  • Recent member
  • *
  • Posts: 22
  • nothing more to say...
Regex
« on: August 23, 2019, 07:40:24 am »

Hi all,

My artist field contains instrument abbriviatios, separated by a colon and empty space between brackets ().
Example: Scott Yancey Avett (l.vcl, b.vcl, bjo, p, a.gtr) - Timothy Seth Avett (l.vcl, b.vcl, a.gtr, e.gtpt, org, cel) - Bob Crawford (cb, e.b.gtr, l.vcl, b.vcl) - Joseph Kwon (vlc)

I want to create a field with unique abbriviations separated by | sorted A-Z:
a.gtr|b.vcl|bjo|cb|cel|e.b.gtr|e.gtpt|l.vcl|org|p|vlc|

I used the regex expression:
\((.*?)\)
wich works fine in regex checkers.

When I use in MC25:
regex([Artist], /#\((.*?)\)#/, 1)
I only get the content from the first set of ():
l.vcl, b.vcl, bjo, p, a.gtr

Could you, please help?

John
 
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Regex
« Reply #1 on: August 23, 2019, 09:30:38 am »

I think I understand what you want:

Look at ALL Artist fields in all files.
Gather list of instrument abbreviations from all.
Sort them alphabetically.
Remove duplicates to produce a unique list.
Separate list elements with the pipe character ( | ).
Put that list somewhere.

If that's what you want, you will need a good bit more than just a regex.  Regex in MC operates on one field in one file at a time.  It outputs values that you determine for that ONE file.  It then goes to the next file and operates on it.  Regex (and other MC expressions) do not store values from previous files.

To store previous values and operate on them, you would need MC's Global Variables feature.  I've used Globals in MC, but it's kind of confusing and I don't remember all of the details.  There's documentation and examples in the Wiki:

https://wiki.jriver.com/index.php/Global_Variables

You could also use an external tool to do this like Mr.C's perl MC system.

I personally would probably be using some kind of export (like exporting an MPL list of the library) and then using an external tool (like Perl or Unix shell tools) to extract, combine, and sort to get the list you want.

If you just want this sorted list for each file, then that's a good bit easier.

Brian.
Logged

sufokeet

  • Regular Member
  • Recent member
  • *
  • Posts: 22
  • nothing more to say...
Re: Regex
« Reply #2 on: August 23, 2019, 07:46:10 pm »

Hi Brian,

Thanks for your respons.
You perfectly understand what I want.

However, my experience with MC25 is different.
I created a new field, and -put the expression:
   regex([Artist], /#\((.*?)\)#/, 1)
in the Expresion box. Its result is the content of what's between the first () combination. De following are ignored. It is so for all, roughly 100.000 files.
In an "normal field it works for the highlighted files.
On sites like:
   http://regexstorm.net/tester
with this regex-code I get exactly what I want. I added a pdf screenshot.
That's why I am wandering if it is a language issue.

The problem with those sites is that they cannot or will not handle the amount of data. They are limited in size or matches.
Even when I exported the Artist-field content as an csv file, and filtered the data. The Miles Davis Quartet has often the same members. The amount of data is still to big.
Cutting it in smaller portions is not a ral option. Too many.

My problem is that I cannot have the code "grap" the data between all the () combinations in MC25 while it is doing so on sites, like mentioned. Just the first!

I'll studie the Global suggestion.

John
Logged
Pages: [1]   Go Up