View Single Post
Old 11-08-2012, 12:11 PM   #1007
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.
 
Posts: 1,676
Karma: 509671
Join Date: Dec 2011
Location: Midwest USA
Device: Nook STR w/Glowlight, Kindle 3g, Droid
'in' is special to Python, but not to regexp, so it doesn't need to be escaped in regular expressions. Nor do commas. Parans--'()'--however, are and should be escaped with '\' when not being used for expression grouping.

This worked for me with this story:

Code:
replace_metadata:
 category=>Alice in Wonderland, 2010=>Alice in Wonderland (2010)
 characters=>Alice K\.=>Other.Alice Kingsleigh&&category=>Alice in Wonderland \(2010\)
 characters=>Mad Hatter/Tarrant Hightopp=>Other.Tarrant Hightop (Mad Hatter)&&category=>Alice in Wonderland \(2010\)
This pattern:

Code:
characters=>Cheshire Cat=>Other.\1&&category=>Alice in Wonderland
...doesn't work because \1 is replaced by the first matched paran group--and this pattern doesn't have one.

This pattern instead:
Code:
characters=>(Cheshire Cat)=>Other.\1&&category=>Alice in Wonderland \(2010\)
...will change 'Cheshire Cat/Chessur' to 'Other.Cheshire Cat/Chessur'. The '/Chessur' part is kept because the pattern only matches 'Cheshire Cat', leaving the rest. To remove it, use:

Code:
characters=>(Cheshire Cat).*=>Other.\1&&category=>Alice in Wonderland \(2010\)
Then the pattern matches the entire string and changes 'Cheshire Cat/Chessur' to 'Other.Cheshire Cat'.
JimmXinu is offline   Reply With Quote