# Problem parsing the input

Harish K Vishwanath harish.shastry at gmail.com
Tue Sep 16 15:32:53 CEST 2008

```Consider the code below :

x = """
... *****
... - Burst_Length not read from ini file
... ?      -
... + BurstLength not read from ini file
... *****
... - PilotTracking_Timing not read from ini file
... ? ^^^^^^^^^^^^^^
... + NumTimings not read from ini file
... - Burst Position = 89511samples
... + Analysis Time (Iterations = 1) = 0.562249s
... +  Rising Edge Time = 371683us
... -  Rising Edge Time = 371682us
... """
>>> x
'\n*****\n- Burst_Length not read from ini file\n?      -\n+ BurstLength not
^^^^^^^^^^^^^^\n+ NumTimings not read from ini file\n- Burst Position =
89511samples\n+ Analysis Time (Iterations = 1) = 0.562249s\n+  Rising Edge
Time = 371683us\n-  Rising Edge Time = 371682us\n'
>>> import re
*>>> num = re.compile('(?P<num>[0-9]+)[^.]')
>>> flt = re.compile('(?P<flt>[0-9]*\.[0-9]*)')
*>>> flt.findall(x)
['0.562249']
>>> num.findall(x)
['89511', '1', '562249', '371683', '371682']

Those regular expressions can fetch the required input.

On Tue, Sep 16, 2008 at 6:20 PM, <dudeja.rajat at gmail.com> wrote:

> Hi,
> I've a following input:
>
> *****
> - Burst_Length not read from ini file
> ?      -
> + BurstLength not read from ini file
> *****
> - PilotTracking_Timing not read from ini file
> ? ^^^^^^^^^^^^^^
> + NumTimings not read from ini file
> *****
> - Analysis Time (Iterations = 1) = 0.519444s
> ?                                     ^ ---
> + Analysis Time (Iterations = 1) = 0.562249s
> *****
> - Burst Position = 89511samples
> ?                      ^
> + Burst Position = 89510samples
> *****
> - Rising Edge Time = 371682us
> ?                         ^
> + Rising Edge Time = 371683us
> *****
>
> How can I find the the colored items from the input. I though of using RE
> but don't know much about it.
>
> The colored item can be dot notation e.g. 0.05678 or a whole digit as 5678
>
>
>
>
> --
> Rajat
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

--
Regards,
Harish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080916/119524ff/attachment.html>
```