Re: regex multiple patterns in order

2014-01-20 Thread Mark Lawrence
On 20/01/2014 17:09, Neil Cerutti wrote: On 2014-01-20, Devin Jeanpierre wrote: On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence wrote: On 20/01/2014 16:04, Neil Cerutti wrote: I use regular expressions regularly, for example, when editing text with gvim. But when I want to use them in Python

Re: regex multiple patterns in order

2014-01-20 Thread Mark Lawrence
On 20/01/2014 17:06, Rustom Mody wrote: On Monday, January 20, 2014 10:10:32 PM UTC+5:30, Devin Jeanpierre wrote: On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence wrote: On 20/01/2014 16:04, Neil Cerutti wrote: I use regular expressions regularly, for example, when editing text with gvim. But wh

Re: regex multiple patterns in order

2014-01-20 Thread Rustom Mody
On Monday, January 20, 2014 10:10:32 PM UTC+5:30, Devin Jeanpierre wrote: > On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence wrote: > > On 20/01/2014 16:04, Neil Cerutti wrote: > >> I use regular expressions regularly, for example, when editing > >> text with gvim. But when I want to use them in Pyth

Re: regex multiple patterns in order

2014-01-20 Thread Neil Cerutti
On 2014-01-20, Devin Jeanpierre wrote: > On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence > wrote: >> On 20/01/2014 16:04, Neil Cerutti wrote: >>> I use regular expressions regularly, for example, when >>> editing text with gvim. But when I want to use them in Python >>> I have to contend with the

Re: regex multiple patterns in order

2014-01-20 Thread Devin Jeanpierre
On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence wrote: > On 20/01/2014 16:04, Neil Cerutti wrote: >> I use regular expressions regularly, for example, when editing >> text with gvim. But when I want to use them in Python I have to >> contend with the re module. I've never become comfortable with >>

Re: regex multiple patterns in order

2014-01-20 Thread Mark Lawrence
On 20/01/2014 16:04, Neil Cerutti wrote: On 2014-01-20, Roy Smith wrote: In article , Ben Finney wrote: Be aware that regex is not the solution to all parsing problems; for many parsing problems it is an attractive but inappropriate tool. You may need to construct a more specific parser for y

Re: regex multiple patterns in order

2014-01-20 Thread Neil Cerutti
On 2014-01-20, Roy Smith wrote: > In article > , Ben > Finney wrote: >> Be aware that regex is not the solution to all parsing >> problems; for many parsing problems it is an attractive but >> inappropriate tool. You may need to construct a more specific >> parser for your needs. Even if it's pos

Re: regex multiple patterns in order

2014-01-20 Thread Roy Smith
In article , Ben Finney wrote: > With a little experimenting I get: > > >>> p = re.compile('((?:CAA)+)?((?:TCT)+)?((?:TA)+)?') > >>> p.findall('CAACAACAATCTTCTTCTTCTTATATA') > [('CAACAACAA', 'TCTTCTTCTTCT', 'TATATA'), ('', '', '')] Perhaps a matter of style, but I would have left o

Re: regex multiple patterns in order

2014-01-20 Thread km
Aah! I understand now. Thank you Regards, Krishna Mohan On Mon, Jan 20, 2014 at 4:48 PM, Ben Finney wrote: > km writes: > > > I am trying to find sub sequence patterns but constrained by the order > > in which they occur > > There are also specific resources for understanding and testing rege

Re: regex multiple patterns in order

2014-01-20 Thread Ben Finney
km writes: > I am trying to find sub sequence patterns but constrained by the order > in which they occur There are also specific resources for understanding and testing regex patterns, such as http://www.pythonregex.com/>. > For example > > >>> p = re.compile('(CAA)+?(TCT)+?(TA)+?') > >>> p.fi

Re: regex multiple patterns in order

2014-01-20 Thread Chris Angelico
On Mon, Jan 20, 2014 at 9:44 PM, km wrote: p = re.compile('(CAA)+?(TCT)+?(TA)+?') p.findall('CAACAACAATCTTCTTCTTCTTATATA') > [('CAA', 'TCT', 'TA')] > > But I instead find only one instance of the CAA/TCT/TA in that order. > How can I get 3 matches of CAA, followed by four matches of TCT

Re: regex multiple patterns in order

2014-01-20 Thread Devin Jeanpierre
On Mon, Jan 20, 2014 at 2:44 AM, km wrote: > I am trying to find sub sequence patterns but constrained by the order in > which they occur > For example > p = re.compile('(CAA)+?(TCT)+?(TA)+?') p.findall('CAACAACAATCTTCTTCTTCTTATATA') > [('CAA', 'TCT', 'TA')] > > But I instead find only o

regex multiple patterns in order

2014-01-20 Thread km
I am trying to find sub sequence patterns but constrained by the order in which they occur For example >>> p = re.compile('(CAA)+?(TCT)+?(TA)+?') >>> p.findall('CAACAACAATCTTCTTCTTCTTATATA') [('CAA', 'TCT', 'TA')] But I instead find only one instance of the CAA/TCT/TA in that order. How can I get