View Single Post
Old 07-21-2013, 02:44 AM   #1543
Jade Aislin
Groupie
Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.
 
Posts: 164
Karma: 3100
Join Date: Sep 2011
Device: Kobo Auro H2O, PRS-T1
Quote:
Originally Posted by JimmXinu View Post
The Spock/Kirk isn't becoming Kirk/Spock because you've left a space in front of Spock and space sorts before 'K'.
Okay. I figured out that problem. I changed the code to this:

Code:
replace_metadata:
 ships=>(( )?(-)?( )?[Bb]rother(s)?(ly )?(love )?|( )?(-)?( )?[Ff]amil(y)?(ial)?( Relationship)?( )?)=> (Family)
 ships=> \(Family\)(.*?)$=>\1 (Family)
Now the one that would not sort is sorting.

Quote:
Originally Posted by JimmXinu View Post
However, you should be able to put your 'tags' at the end using replace_metadata with ships_LIST. Match "(Family|etc) name/other name" and swap it around.

Keep in mind that you're dealing with the whole list at that point, you can match on the commas between and end of string. If there are commas in any of the names it will cause problems, but could that be handled by changing join_string_ships and reverting it afterwards with another ships_LIST regex. (Or by removing commas before all your processing probably a better solution for calibre tag-like columns.)

You'll also need additional complexity for 3, 4, 5, etc ways if you want those to work the same.
I think I finally figured it out.

I now have this code:

Code:
replace_metadata:
 #Convert keywords to end tags.
  ships=>(( )?(-)?( )?[Bb]rother(s)?(ly )?(love )?|( )?(-)?( )?[Ff]amil(y)?(ial)?( Relationship)?( )?)=> (Family)
  
#Place the end tag at the end of the ship.

 ships=> \(Family\)(.*?)$=>\1 (Family)
 

  #sort the names in the ships (code is in the default for all sites)
 
 #Place the end tag at the end of the ship using ships_LIST
 ships_LIST=>(\(Family\)|\(Friendship\))( )?(.*?),=>\3 \1,
 ships_LIST=>,(.*?)( \(Family\)|\(Friendship\))/(.*?)$=>,\1/\3\2


 #get rid of space before the '/'

  ships_LIST=> /=>/
It took me a while to figure out what you meant by commas. Then I had trouble figuring out how to deal with the last ship in the string.

Next up, reworking the code to separate ships with more than one end tag into their own ships (ie: A/B (Friendship) (Past), becomes: A/B (Friendship), A/B (Past).)

I'm hoping it will be as simple as using the code I had for ships with a comma at the beginning of the regex. However, I'll work on that another day.

I'm actually proud of myself. I rewrote this message three or four times because I figured out how to fix my problems with putting the end tag at the end.

Thanks for all the help.
Jade Aislin is offline