View Single Post
Old 11-12-2012, 10:02 PM   #1024
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
'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:
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'.
Thanks, I hadn't realized the \1 was looking for parenthesis. I think I finished all the regex replacements I need for FFN.
Jade Aislin is offline