Author Topic: Using parts of Filename for Metadata  (Read 3557 times)

0 Members and 1 Guest are viewing this topic.

Padanges

  • Newbie
  • *
  • Posts: 179
Using parts of Filename for Metadata
« on: August 16, 2016, 02:40:45 PM »
Hi,
in a situation like this: https://regex101.com/r/xF7pK7/5 we have only one match and it's number is not 1 (but 3), while it is possible to find a Filename which has an opposite situation (where the match number is 1): https://regex101.com/r/xF7pK7/6 . You sugested a script (http://www.rttsoftware.com/forum/index.php/topic,458.0.html) which has line: "return match[1]".  Is there any way to define a match in a different way?

RTT

  • Administrator
  • *****
  • Posts: 907
Re: Using parts of Filename for Metadata
« Reply #1 on: August 17, 2016, 12:10:06 AM »
Different way from what? Without the use of regular expressions, or a regular expression that will get the author always at the 1st capturing group for that format of file names?

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using parts of Filename for Metadata
« Reply #2 on: August 17, 2016, 06:45:30 AM »
Imagine that someone is using your script sample just by changing the reg expression. There is a situation where he gets a wrong statement evaluation only because his reg expression is complex and his pattern match is not numbered as 1. I was asking perhaps you know, from your experience, how to select differently the matching string, i.e. not using the syntax with number "1" ("return match[1]").
For a current reg expression I found a workaround: "return (match[1] || match[3]);".

RTT

  • Administrator
  • *****
  • Posts: 907
Re: Using parts of Filename for Metadata
« Reply #3 on: August 18, 2016, 12:33:42 AM »
That script sample is specific to the given filename format example. It gives some implementations ideas but obviously if the used regex gives different results, the script must change too.
With your example, Title (Author, 2nd Ed, 2000), I think a better approach would be to split the text inside the parenthesis, using the javascript split function (comma as delimiter), and then extract each individual item from the result array, taking into account the length of the array to infer the presence or not of a given item.

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using parts of Filename for Metadata
« Reply #4 on: August 18, 2016, 06:46:39 AM »
Thanks for sharing thoughts.