View Single Post
Old 05-06-2013, 09:50 PM   #1361
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
Only the part that matches the regex is replaced. If you want to add something to the end, you'll need to match the rest of the string. Something like this should work:

ships=>( )?(&|and)(.*?)$=>\1 \3 (Friendship)
That seemed to work. Although, I changed the code to get the '/' between the names. As well as making the first space neccessary. It was accepting 'and' when it was part of a person's name, like 'Gandalf'.

New code:
ships=> (&|and)(.*?)$=>/\3 (Friendship)

However, I was only able to test it once before I started getting an 'invalid group reference' for all the stories I had already.

Quote:
Originally Posted by JimmXinu View Post
There is a known issue(look for "Brief explanation") with python's regex library not handling group matching the same as everybody else.
While I was looking up the reference you gave me, the 'unmatched group' seemed to resolve itself. However, I am still getting the 'invalid group reference'. I tried looking it up and it looked like it might be a problem with '$' when not used as an end of string reference. As far as I know my code only uses the $ to indicate the end of the string I want. Is that the only reason I would get that error?
Jade Aislin is offline