Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11801 > unrolled thread
| Started by | Matt Funk <matze999@gmail.com> |
|---|---|
| First post | 2011-08-18 13:49 -0600 |
| Last post | 2011-08-18 20:00 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Help with regular expression in python Matt Funk <matze999@gmail.com> - 2011-08-18 13:49 -0600
Re: Help with regular expression in python John Gordon <gordon@panix.com> - 2011-08-18 20:00 +0000
| From | Matt Funk <matze999@gmail.com> |
|---|---|
| Date | 2011-08-18 13:49 -0600 |
| Subject | Help with regular expression in python |
| Message-ID | <mailman.191.1313697016.27778.python-list@python.org> |
Hi,
i am sorry if this doesn't quite match the subject of the list. If someone
takes offense please point me to where this question should go. Anyway, i have
a problem using regular expressions. I would like to match the line:
1.002000e+01 2.037000e+01 2.128000e+01 1.908000e+01 1.871000e+01 1.914000e+01
2.007000e+01 1.664000e+01 2.204000e+01 2.109000e+01 2.209000e+01 2.376000e+01
2.158000e+01 2.177000e+01 2.152000e+01 2.267000e+01 1.084000e+01 1.671000e+01
1.888000e+01 1.854000e+01 2.064000e+01 2.000000e+01 2.200000e+01 2.139000e+01
2.137000e+01 2.178000e+01 2.179000e+01 2.123000e+01 2.201000e+01 2.150000e+01
2.150000e+01 2.199000e+01 : (instance: 0) : some description
The number of floats can vary (in this example there are 32). So what i thought
i'd do is the following:
instance_linetype_pattern_str = '([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)
{32}'
instance_linetype_pattern = re.compile(instance_linetype_pattern_str)
Basically the expression in the first major set of paranthesis matches a
scientific number format. The '{32}' is supposed to match the previous 32
times. However, it doesn't. I can't figure out why this does not work. I'd
really like to understand it if someone can shed light on it.
thanks
matt
[toc] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2011-08-18 20:00 +0000 |
| Message-ID | <j2jr09$sp3$1@reader1.panix.com> |
| In reply to | #11801 |
In <mailman.191.1313697016.27778.python-list@python.org> Matt Funk <matze999@gmail.com> writes:
> 1.002000e+01 2.037000e+01 2.128000e+01 1.908000e+01 1.871000e+01 1.914000e+01
> instance_linetype_pattern_str = '([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)
> {32}'
> instance_linetype_pattern = re.compile(instance_linetype_pattern_str)
Does your regexp account for the space in between each float? I can't tell
due to your post having a linebreak at a really inconvenient spot.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web