View Single Post
Old 07-22-2013, 12:54 AM   #1548
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,025
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by Jade Aislin View Post
I have most of the coding done for my end tags, but I had a few questions.

1. In order to get the end tags to the end of a ship when there is more than one end tag, I had to duplicate a couple lines of code.
...
Is there a way to tell it to redo a line of code until it no longer finds what the code is looking for?
No, there isn't. And I'm not inclined to add such a feature. I expect most users would end up creating infinite loops more often than not.

Since you're matching the rest of the entry too, I suspect multiple lines may be as good as it gets.

Quote:
Originally Posted by Jade Aislin View Post
2. When I put in code for putting the end tag at the end for the final ship in the list, I had to delete a space from the code to make it work.
...
Originally I tried to put in ( )? to show that the space might not be there.
...
However, I received an unmatched group error when I added the '( )?'.

Is there a way I can streamline these two lines of code?
Python regex has what is IMHO, a flaw. Unmatched group replacements (\1,\2,etc) instead of being ignore throw exceptions. There's a work around for it--'(| )' I think in this case--and it's been discussed in this thread in past. Google will also find various workarounds and comments.

As for streamlining, instead of two lines, one ending in ", " and one with "$", try "(, |$)".

Quote:
Originally Posted by Jade Aislin View Post
3. Finally, I used this code to separate end tags into different ships:
...
I'm not sure why it deleted the second end tag. I also tested '\1 (\3), \1 (\2)' and still had the second tag deleted. I'm not really sure how to fix the last line to get the last ship in the list fixed.
I suspect that combining them into one line with "(, |$)" will help.
JimmXinu is offline