Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64353 > unrolled thread
| Started by | km <srikrishnamohan@gmail.com> |
|---|---|
| First post | 2014-01-20 16:14 +0530 |
| Last post | 2014-01-20 16:14 +0530 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
regex multiple patterns in order km <srikrishnamohan@gmail.com> - 2014-01-20 16:14 +0530
| From | km <srikrishnamohan@gmail.com> |
|---|---|
| Date | 2014-01-20 16:14 +0530 |
| Subject | regex multiple patterns in order |
| Message-ID | <mailman.5745.1390215221.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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 3 matches of CAA, followed by four matches of TCT followed
by 2 matches of TA ?
Well these patterns (CAA/TCT/TA) can occur any number of times and atleast
once so I have to use + in the regex.
Please let me know.
Thanks!
Regards,
Krishna mohan
Back to top | Article view | comp.lang.python
csiph-web