View Single Post
Old 10-14-2021, 05:43 PM   #6542
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,033
Karma: 4604637
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by Hortensia View Post
Using the personal.ini file, I am trying to simplify the ships tags which are automatically downloaded with the fic from: "Character A & Character B, Character A/Character B" to "Character A/Character B".
If you simply change all '&' to '/', that will accomplish what you literally ask:

Code:
sort_ships:true
sort_ships_splits:
 [ ]*/[ ]*=>/
 [ ]*&[ ]*=>/
"Character A & Character B, Character A/Character B" becomes "Character A/Character B, Character A/Character B" and then the built-in de-duping will reduce it to "Character A/Character B".

However, that will affect all values of ships.

If what you mean is to remove "Character A & Character B" only when "Character A/Character B" is also present--and not change "Character C & Character D" to "Character C/Character D", that's more complex.

Instead of changing sort_ships_splits, you would use replace_metadata. sort_ships:true is still needed to catch "Character A & Character B" vs "Character B & Character A" (note order), and you cannot have set keep_in_order_ships:true--this solution depends on having the & version immediately before the / version.

Code:
sort_ships:true
replace_metadata:
  ships_LIST=>([^&]+) & ([^&]+), \1/\2=>\1/\2
The \1 and \2 match the prior () groupings as usual for regex.

You have to use ships_LIST instead of just ships because otherwise the & and / entries are treated separately.

This works for the small handful of test cases I've done, but I won't be surprised if it has issues I haven't thought of.

It's usually easier to talk about concrete examples (ideally with story URLs) than in the abstract, BTW. Then we can test directly.
JimmXinu is offline   Reply With Quote