in reply to Regex Parsing Chars in a Line

If you accept swl's suggestion that the separator should be qr/ - /, and only use the first two fields, the Milne entry would not be an exception. 'Series' fields would still be a problem. Neither your text nor your code tell us anything about how you might recognize them. You have not even provided a single example. Of course, you could avoid this problem by using the last field instead of the second. Then Milne would be a problem again, not because of the extra hyphens, but because it does not fit the format.
Bill

Replies are listed 'Best First'.
Re^2: Regex Parsing Chars in a Line
by kel (Sexton) on Nov 26, 2019 at 05:53 UTC
    The actual code is real simple but an actual script would be deadly if run in a wrong directory. I have neglected to write safety features in them. But in essence it is simply: Parsing a directory of media files. In a loop, running each file through dozens of filters to reformat names and titles, and to remove any unnecessary desiderata. I use hyphens as my main field seperators, so only need two: Author and Title, but can accomodate a third. For example it is important in Fiction to keep Author field first, as that is used to further parse into categories, which is often parsed from from the Title (and extra Series/Subtitle) fields. The opposite is true in Nonfiction, where the author is often optional (as the publisher may be more relevant). Plus, there are *many* scripts and functions, each used as needed. Some will create underscores, and encapsulate dates, others will remove them.