Re: Extracting parts of string between anchor points

2014-02-27 Thread Denis McMahon
On Fri, 28 Feb 2014 00:55:01 +, Denis McMahon wrote: > The code in the file at the url below processes 17 different cases. It > may help, or it may confuse. > http://www.sined.co.uk/tmp/strparse.py.txt I added some more cases to it, and then realised that the code could actually be simplifi

Re: Extracting parts of string between anchor points

2014-02-27 Thread Denis McMahon
On Thu, 27 Feb 2014 20:07:56 +, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure it's > regular expression I need to achieve this more but not very familiar > with use regex, particularly retaining part of the string that is being > searched/matched for.

Re: Extracting parts of string between anchor points

2014-02-27 Thread Tim Chase
On 2014-02-27 15:45, Tim Chase wrote: > >>> r = re.compile(r"^([^:]*)(?::((?:(?!-:-).)*)(?:-:-(.*))?)?") If you want to compare both the re method and the string method, here's a test-harness to play with: import re examples = [ ("", (None, None, None)), ("Test1A", ("Test1A", None, No

Re: Extracting parts of string between anchor points

2014-02-27 Thread Tim Chase
On 2014-02-27 20:07, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure > it's regular expression I need to achieve this more but not very > familiar with use regex, particularly retaining part of the string > that is being searched/matched for. While I suppose

Re: Extracting parts of string between anchor points

2014-02-27 Thread Cameron Simpson
On 27Feb2014 20:07, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure it's > regular expression I need to achieve this more but not very familiar with > use regex, particularly retaining part of the string that is being > searched/matched for. Regexps are qui