Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal point,
> but leave one zero if it's whole number.
def strip_zero(s):
if '.' not in s:
return s
s = s.rstrip('0')
if s.endswith('.'):
s += '0'
return s
And in use:
py> strip_
On 13Mar2015 12:05, Larry Martell wrote:
I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.75471698113207
On Fri, Mar 13, 2015 at 1:29 PM, MRAB wrote:
> On 2015-03-13 16:05, Larry Martell wrote:
>>
>> I need to remove all trailing zeros to the right of the decimal point,
>> but leave one zero if it's whole number. For example, if I have this:
>>
>>
>> 14S,5.,4.5686274500,3.72727272
On 2015-03-13 12:05, Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal
> point, but leave one zero if it's whole number.
>
> But I can't figure out how to get the 5. to be 5.0.
> I've been messing with the negative lookbehind, but I haven't fou
On 2015-03-13 16:05, Larry Martell wrote:
I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.75471698113207
Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal point,
> but leave one zero if it's whole number. For example, if I have this:
>
>
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.94230769
I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.1
On Mon, 06 Dec 2010 18:12:33 +0100, Peter Otten wrote:
> By the way:
>
print quopri.decodestring("=E4=F6=FC").decode("iso-8859-1")
> äöü
print r"\xe4\xf6\xfc".decode("string-escape").decode("iso-8859-1")
> äöü
Ah - better than a regex. Thanks!
--
http://mail.python.org/mailman/listin
Dan M wrote:
> I'm getting bogged down with backslash escaping.
>
> I have some text files containing characters with the 8th bit set. These
> characters are encoded one of two ways: either "=hh" or "\xhh", where "h"
> represents a hex digit, and "\x" is a literal backslash followed by a
> lower-
On Mon, 06 Dec 2010 09:44:39 -0600, Dan M wrote:
> That's what I had initially assumed was the case, but looking at the
> data files with a hex editor showed me that I do indeed have
> four-character sequences. That's what makes this such as interesting
> task!
Sorry, I misunderstood the first ti
On Mon, 06 Dec 2010 16:34:56 +0100, Alain Ketterlin wrote:
> Dan M writes:
>
>> I took at look at http://docs.python.org/howto/regex.html, especially
>> the section titled "The Backslash Plague". I started out trying :
>
> import re
> r = re.compile('x([0-9a-fA-F]{2})') a = "This \x
On Mon, 06 Dec 2010 10:29:41 -0500, Mel wrote:
> What you're missing is that string `a` doesn't actually contain four-
> character sequences like '\', 'x', 'a', 'a' . It contains single
> characters that you encode in string literals as '\xaa' and so on. You
> might do better with
>
> p1 = r'([
Dan M writes:
> I took at look at http://docs.python.org/howto/regex.html, especially the
> section titled "The Backslash Plague". I started out trying :
import re
r = re.compile('x([0-9a-fA-F]{2})')
a = "This \xef file \xef has \x20 a bunch \xa0 of \xb0 crap \xc0
The backs
Dan M wrote:
> I'm getting bogged down with backslash escaping.
>
> I have some text files containing characters with the 8th bit set. These
> characters are encoded one of two ways: either "=hh" or "\xhh", where "h"
> represents a hex digit, and "\x" is a literal backslash followed by a
> lower-
I'm getting bogged down with backslash escaping.
I have some text files containing characters with the 8th bit set. These
characters are encoded one of two ways: either "=hh" or "\xhh", where "h"
represents a hex digit, and "\x" is a literal backslash followed by a
lower-case x.
Catching the f
On Apr 8, 3:40 pm, gry wrote:
> > >>> s='555tHe-rain.in#=1234'
> > >>> import re
> > >>> r=re.compile(r'([a-zA-Z]+|\d+|.)')
> > >>> r.findall(s)
> > ['555', 'tHe', '-', 'rain', '.', 'in', '#', '=', '1234']
>
> This is nice and simple and has the invertible property that Patrick
> me
> >>> s='555tHe-rain.in#=1234'
> >>> import re
> >>> r=re.compile(r'([a-zA-Z]+|\d+|.)')
> >>> r.findall(s)
> ['555', 'tHe', '-', 'rain', '.', 'in', '#', '=', '1234']
This is nice and simple and has the invertible property that Patrick
mentioned above. Thanks much!
--
http://mail.py
On 8 Apr, 19:49, gry wrote:
> [ python3.1.1, re.__version__='2.2.1' ]
> I'm trying to use re to split a string into (any number of) pieces of
> these kinds:
> 1) contiguous runs of letters
> 2) contiguous runs of digits
> 3) single other characters
>
> e.g. 555tHe-rain.in#=1234 should give:
On Apr 8, 3:40 pm, MRAB wrote:
...
> Group 1 and group 4 match '='.
> Group 1 and group 3 match '1234'.
>
> If a group matches then any earlier match of that group is discarded,
Wow, that makes this much clearer! I wonder if this behaviour
shouldn't be mentioned in some form in the python docs?
gry wrote:
[ python3.1.1, re.__version__='2.2.1' ]
I'm trying to use re to split a string into (any number of) pieces of
these kinds:
1) contiguous runs of letters
2) contiguous runs of digits
3) single other characters
e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain',
'.',
On Apr 8, 1:49 pm, gry wrote:
> [ python3.1.1, re.__version__='2.2.1' ]
> I'm trying to use re to split a string into (any number of) pieces of
> these kinds:
> 1) contiguous runs of letters
> 2) contiguous runs of digits
> 3) single other characters
>
> e.g. 555tHe-rain.in#=1234 should give:
On 8 Apr, 19:49, gry wrote:
> [ python3.1.1, re.__version__='2.2.1' ]
> I'm trying to use re to split a string into (any number of) pieces of
> these kinds:
> 1) contiguous runs of letters
> 2) contiguous runs of digits
> 3) single other characters
>
> e.g. 555tHe-rain.in#=1234 should give:
gry wrote:
[ python3.1.1, re.__version__='2.2.1' ]
I'm trying to use re to split a string into (any number of) pieces of
these kinds:
1) contiguous runs of letters
2) contiguous runs of digits
3) single other characters
e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain',
'.',
[ python3.1.1, re.__version__='2.2.1' ]
I'm trying to use re to split a string into (any number of) pieces of
these kinds:
1) contiguous runs of letters
2) contiguous runs of digits
3) single other characters
e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain',
'.', 'in', '#', '=
# http://gist.github.com/271661
import lxml.html
import re
src = """
lksjdfls kdjff lsdfs sdjfls sdfsdwelcome
hello, my age is 86 years old and I was born in 1945. Do you know
that
PI is roughly 3.1443534534534534534 """
regex = re.compile('amazon_(\d+)')
doc = lxml.html.document_fromstring(s
In article <19de1d6e-5ba9-42b5-9221-ed7246e39...@u36g2000prn.googlegroups.com>,
Oltmans wrote:
>
>I've written this regex that's kind of working
>re.findall("\w+\s*\W+amazon_(\d+)",str)
>
>but I was just wondering that there might be a better RegEx to do that
>same thing. Can you kindly suggest a
On 21.12.2009 12:38, Oltmans wrote:
Hello,. everyone.
I've a string that looks something like
lksjdfls kdjff lsdfs sdjflssdfsdwelcome
> From above string I need the digits within the ID attribute. For
example, required output from above string is
- 35343433
- 345343
- 8898
I've w
On Dec 21, 5:38 am, Oltmans wrote:
> Hello,. everyone.
>
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I need the digits within the ID attribute. For
> example, required output from above string is
how about re.findall(r'\w+.=\W\D+(\d+)?',str) ?
this will work for any string within id !
~Ukanth
On Dec 21, 6:06 pm, Oltmans wrote:
> On Dec 21, 5:05 pm, Umakanth wrote:
>
> > How about re.findall(r'\d+(?:\.\d+)?',str)
>
> > extracts only numbers from any string
>
> Thank you. However, I
> Oltmans wrote:
> >I've a string that looks something like
> >
> >lksjdfls kdjff lsdfs sdjfls >= "amazon_35343433">sdfsdwelcome
> >
> >
> >>From above string I need the digits within the ID attribute. For
> >example, required output from above string is
> >- 35343433
> >- 345343
> >-
Oltmans wrote:
Hello,. everyone.
I've a string that looks something like
lksjdfls kdjff lsdfs sdjfls sdfsdwelcome
From above string I need the digits within the ID attribute. For
example, required output from above string is
- 35343433
- 345343
- 8898
I've written this regex that
Ok. how about re.findall(r'\w+_(\d+)',str) ?
returns ['345343', '35343433', '8898', '8898'] !
On Dec 21, 6:06 pm, Oltmans wrote:
> On Dec 21, 5:05 pm, Umakanth wrote:
>
> > How about re.findall(r'\d+(?:\.\d+)?',str)
>
> > extracts only numbers from any string
>
> Thank you. However, I only
On Dec 21, 5:05 pm, Umakanth wrote:
> How about re.findall(r'\d+(?:\.\d+)?',str)
>
> extracts only numbers from any string
>
Thank you. However, I only need the digits within the ID attribute of
the DIV. Regex that you suggested fails on the following string
lksjdfls kdjff lsdfs sdjfl
Oltmans wrote:
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I need the digits within the ID attribute. For
> example, required output from above string is
> - 35343433
> - 345343
> - 8898
>
> I'v
On Dec 21, 7:38 pm, Oltmans wrote:
> Hello,. everyone.
>
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I need the digits within the ID attribute. For
> example, required output from above string is
How about re.findall(r'\d+(?:\.\d+)?',str)
extracts only numbers from any string
~uk
On Dec 21, 4:38 pm, Oltmans wrote:
> Hello,. everyone.
>
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I n
Hello,. everyone.
I've a string that looks something like
lksjdfls kdjff lsdfs sdjfls sdfsdwelcome
>From above string I need the digits within the ID attribute. For
example, required output from above string is
- 35343433
- 345343
- 8898
I've written this regex that's kind of working
On Wed, Dec 16, 2009 at 10:46 PM, Gabriel Rossetti <
gabriel.rosse...@arimaz.com> wrote:
> Hello everyone,
>
> I'm going nuts with some regex, could someone please show me what I'm doing
> wrong?
>
> I have an XMPP msg :
>
>
>
>
> 123
> 456
>
> ...
>
On Dec 16, 10:22 am, r0g wrote:
> Gabriel Rossetti wrote:
> > Hello everyone,
>
> > I'm going nuts with some regex, could someone please show me what I'm
> > doing wrong?
>
> > I have an XMPP msg :
>
>
>
> > Does someone know what is wrong with my expression? Thank you, Gabriel
>
> Gabriel, tryin
Gabriel Rossetti wrote:
> Hello everyone,
>
> I'm going nuts with some regex, could someone please show me what I'm
> doing wrong?
>
> I have an XMPP msg :
>
>
>
> Does someone know what is wrong with my expression? Thank you, Gabriel
Gabriel, trying to debug a long regex in situ can be a
Hello everyone,
I'm going nuts with some regex, could someone please show me what I'm
doing wrong?
I have an XMPP msg :
123
456
...
the node may be absent or empty (), the node
may be absent. I'd like to grab everything exept the
David wrote:
>
>
> Open:
>
> 5.50
>
>
> Mkt Cap:
>
> 6.92M
>
>
> P/E:
>
> 21.99
>
>
>
> I want to extract the open, mkt cap and P/E values - but apart from
> doing loads of indivdual REs which I think would look messy, I can't
> think of a better and neater looking way. Any ideas?
On Wed, 08 Jul 2009 23:06:22 +0100, David
wrote:
Hi
I have a few regexs I need to do, but im struggling to come up with a
nice way of doing them, and more than anything am here to learn some
tricks and some neat code rather than getting an answer - although
thats obviously what i would like
On 2009-07-08, Chris Rebert wrote:
> On Wed, Jul 8, 2009 at 3:06 PM, David wrote:
>> I want to extract the open, mkt cap and P/E values - but apart from
>> doing loads of indivdual REs which I think would look messy, I can't
>> think of a better and neater looking way. Any ideas?
You are download
On Wed, Jul 8, 2009 at 3:06 PM, David wrote:
> Hi
>
> I have a few regexs I need to do, but im struggling to come up with a
> nice way of doing them, and more than anything am here to learn some
> tricks and some neat code rather than getting an answer - although
> thats obviously what i would like
Hi
I have a few regexs I need to do, but im struggling to come up with a
nice way of doing them, and more than anything am here to learn some
tricks and some neat code rather than getting an answer - although
thats obviously what i would like to get to.
Problem 1 -
(25.47%)
I want to extract 25
In message <[EMAIL PROTECTED]>, Support
Desk wrote:
> Thanks for the reply ...
A: The vulture doesn't get Frequent Poster miles.
Q: What's the difference between a top-poster and a vulture?
--
http://mail.python.org/mailman/listinfo/python-list
Kirk,
That's exactly what I needed. Thx!
-Original Message-
From: Kirk Strauser [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 24, 2008 11:42 AM
To: python-list@python.org
Subject: Re: More regex help
At 2008-09-24T16:25:02Z, "Support Desk" <[EMAIL PROTECTED
At 2008-09-24T16:25:02Z, "Support Desk" <[EMAIL PROTECTED]> writes:
> I am working on a python webcrawler, that will extract all links from an
> html page, and add them to a queue, The problem I am having is building
> absolute links from relative links, as there are so many different types of
> r
I am working on a python webcrawler, that will extract all links from an
html page, and add them to a queue, The problem I am having is building
absolute links from relative links, as there are so many different types of
relative links. If I just append the relative links to the current url, some
w
Thanks for the reply, I found out the problem was occurring later on in the
script. The regexp works well.
-Original Message-
From: Lawrence D'Oliveiro [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 23, 2008 6:51 PM
To: python-list@python.org
Subject: Re: Regex Help
In me
In message <[EMAIL PROTECTED]>, Support
Desk wrote:
> Anybody know of a good regex to parse html links from html code? The one I
> am currently using seems to be cutting off the last letter of some links,
> and returning links like
>
> http://somesite.co
>
> or http://somesite.ph
>
> the code I
Hello,
> Anybody know of a good regex to parse html links from html code?
BeautifulSoup is *the* library to handle HTML
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
soup = BeautifulSoup(urlopen("http://python.org/";))
for a in soup("a"):
print a["href"]
HTH,
--
Miki <[
Support Desk wrote:
the code I am using is
regex = r''
that's way too fragile to work with real-life HTML (what if the link has
a TITLE attribute, for example? or contains whitespace after the HREF?)
you might want to consider using a real HTML parser for this task.
page_text = urllib.
Anybody know of a good regex to parse html links from html code? The one I
am currently using seems to be cutting off the last letter of some links,
and returning links like
http://somesite.co
or http://somesite.ph
the code I am using is
regex = r''
page_text = urllib.urlopen('http://somesit
" % item
... else:
... print "%d valid" % item
...
281 invalid
713 invalid
832 invalid
1281 invalid
1713 invalid
1832 invalid
2281 valid
2713 valid
2832 valid
>>>
_
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Support Desk
Se
Le Monday 30 June 2008 16:53:54 Support Desk, vous avez écrit :
> Hello,
>I am working on a web-app, that querys long distance numbers from a
> database of call logs. I am trying to put together a regex that matches any
> number that does not start with the following. Basically any number that
Hello,
I am working on a web-app, that querys long distance numbers from a
database of call logs. I am trying to put together a regex that matches any
number that does not start with the following. Basically any number that
does'nt start with:
281
713
832
or
1281
1713
1832
Thats it exactly..thx
-Original Message-
From: Reedick, Andrew [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 03, 2008 9:26 AM
To: Support Desk
Subject: RE: regex help
The regex will now skip anything with an '@'in the filename on the
assumption it's already in the
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> On Behalf Of Support Desk
> Sent: Tuesday, June 03, 2008 9:32 AM
> To: python-list@python.org
> Subject: regex help
>
> I am trying to put together a regular expression that will
> rename users address books on
I am trying to put together a regular expression that will rename users
address books on our server due to a recent change we made. Users with
address books user.abook need to be changed to [EMAIL PROTECTED] I'm
having trouble with the regex. Any help would be appreciated.
-Mike
--
http://mai
On Feb 23, 8:53 am, "amadain" <[EMAIL PROTECTED]> wrote:
> On Feb 23, 8:46 am, "amadain" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Feb 21, 11:15 pm, [EMAIL PROTECTED] wrote:
>
> > > On Feb 21, 6:13 pm, [EMAIL PROTECTED] wrote:
>
> > > > I have apexpectscript to walk through a cisco terminal server an
On Feb 23, 8:46 am, "amadain" <[EMAIL PROTECTED]> wrote:
> On Feb 21, 11:15 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On Feb 21, 6:13 pm, [EMAIL PROTECTED] wrote:
>
> > > I have apexpectscript to walk through a cisco terminal server and I
> > > was hoping to get some help with this regex because I rea
On Feb 21, 11:15 pm, [EMAIL PROTECTED] wrote:
> On Feb 21, 6:13 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > I have apexpectscript to walk through a cisco terminal server and I
> > was hoping to get some help with this regex because I really suck at
> > it.
>
> > This is the code:
>
> > index = s
On Feb 21, 6:13 pm, [EMAIL PROTECTED] wrote:
> I have a pexpect script to walk through a cisco terminal server and I
> was hoping to get some help with this regex because I really suck at
> it.
>
> This is the code:
>
> index = s.expect(['login: ', pexpect.EOF, pexpect.TIMEOUT])
> i
I have a pexpect script to walk through a cisco terminal server and I
was hoping to get some help with this regex because I really suck at
it.
This is the code:
index = s.expect(['login: ', pexpect.EOF, pexpect.TIMEOUT])
if index == 0:
m = re.search('((#.+\r\n){20,25})
MooMaster Wrote:
> I'm trying to develop a little script that does some string
> manipulation. I have some few hundred strings that currently look like
> this:
> cond(a,b,c)
> and I want them to look like this:
> cond(c,a,b)
I zoned out on your question and created a very simple flipper.
Although
"MooMaster" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm trying to develop a little script that does some string
> manipulation. I have some few hundred strings that currently look like
> this:
>
> cond(a,b,c)
>
> and I want them to look like this:
>
> cond(c,a,b)
Pyparsing
MooMaster wrote:
> I'm trying to develop a little script that does some string
> manipulation. I have some few hundred strings that currently look like
> this:
>
> cond(a,b,c)
>
> and I want them to look like this:
>
> cond(c,a,b)
>
> but it gets a little more complicated because the conds themselv
> cond(a,b,c)
>
> and I want them to look like this:
>
> cond(c,a,b)
>
> but it gets a little more complicated because the conds themselves may
> have conds within, like the following:
>
> cond(0,cond(c,cond(e,cond(g,h,(ahttp://mail.python.org/mailman/listinfo/python-list
I'm trying to develop a little script that does some string
manipulation. I have some few hundred strings that currently look like
this:
cond(a,b,c)
and I want them to look like this:
cond(c,a,b)
but it gets a little more complicated because the conds themselves may
have conds within, like the
Why not use split instead of regular expressions?
>>> ln = "3232 23 9 9 - 9 9 - 911
>>> 110"
>>> ln.split()
['32', '32', '23', '9', '9', '-', '9', '9', '-', '9', '11', '1', '10']
Much simpler, yes? Just find the line that comes after a line that
Lance Hoffmeyer wrote:
> I have the following table and I am trying to match percentage the 2nd
> column on the 2nd Tiger line (9.0).
>
> I have tried both of the following. I expected both to match but neither
> did? Is there a modifier
> I am missing? What changes do I need to make these mat
I have the following table and I am trying to match percentage the 2nd column
on the 2nd Tiger line (9.0).
I have tried both of the following. I expected both to match but neither did?
Is there a modifier
I am missing? What changes do I need to make these match? I need to keep the
structure
rh0dium wrote:
> Michael Spencer wrote:
>> >>> def parse(source):
>> ... source = source.splitlines()
>> ... original, rest = source[0], "\n".join(source[1:])
>> ... return original, rest_eval(get_tokens(rest))
>
> This is a very clean and elegant way to separate them - Very ni
"rh0dium" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Paul McGuire wrote:
>
> > ident = Combine( Word(alpha,alphanums+"_") + LPAR + RPAR )
>
> This will only work for a word with a parentheses ( ie. somefunction()
> )
>
> > If you *really* want everything on the first line to b
Michael Spencer wrote:
> >>> def parse(source):
> ... source = source.splitlines()
> ... original, rest = source[0], "\n".join(source[1:])
> ... return original, rest_eval(get_tokens(rest))
This is a very clean and elegant way to separate them - Very nice!! I
like this alot -
Paul McGuire wrote:
> ident = Combine( Word(alpha,alphanums+"_") + LPAR + RPAR )
This will only work for a word with a parentheses ( ie. somefunction()
)
> If you *really* want everything on the first line to be the ident, try this:
>
> ident = Word(alpha,alphanums+"_") + restOfLine
> or
> ide
rh0dium wrote:
> Hi all,
>
> I am using python to drive another tool using pexpect. The values
> which I get back I would like to automatically put into a list if there
> is more than one return value. They provide me a way to see that the
> data is in set by parenthesising it.
>
...
>
> CAN S
"rh0dium" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Paul McGuire wrote:
> > -- Paul
> > (Download pyparsing at http://pyparsing.sourceforge.net.)
>
> Done.
>
>
> Hey this is pretty cool! I have one small problem that I don't know
> how to resolve. I want the entire contents
Paul McGuire wrote:
> -- Paul
> (Download pyparsing at http://pyparsing.sourceforge.net.)
Done.
Hey this is pretty cool! I have one small problem that I don't know
how to resolve. I want the entire contents (whatever it is) of line 1
to be the ident. Now digging into the code showed a method
rovide me a way to see that the
> data is in set by parenthesising it.
>
Well, you asked for regex help, but a pyparsing rendition may be easier to
read and maintain.
-- Paul
(Download pyparsing at http://pyparsing.sourceforge.net.)
# test data strings
test1 = """somefunction(
Hi all,
I am using python to drive another tool using pexpect. The values
which I get back I would like to automatically put into a list if there
is more than one return value. They provide me a way to see that the
data is in set by parenthesising it.
This is all generated as I said using pexpec
John Machin wrote:
> jeff sacksteder wrote:
>> Regex questions seem to be rather resistant to googling.
>>
>> My regex currently looks like - 'FOO:.*\n\n'
>>
>> The chunk of text I am attempting to locate is a line beginning with
>> "FOO:", followed by an unknown number of lines, terminating wit
when *I* google
http://www.awaretek.com/tutorials.html#regular
http://en.wikibooks.org/wiki/Programming:Python_Strings
http://www.regexlib.com/Default.aspx
http://docs.python.org/lib/module-re.html
http://diveintopython.org/regular_expressions/index.html#re.intro
http://www.amk.ca/python/howto/r
jeff sacksteder wrote:
> Regex questions seem to be rather resistant to googling.
>
> My regex currently looks like - 'FOO:.*\n\n'
>
> The chunk of text I am attempting to locate is a line beginning with
> "FOO:", followed by an unknown number of lines, terminating with a
> blank line. Clearly th
jeff sacksteder wrote:
> Regex questions seem to be rather resistant to googling.
>
> My regex currently looks like - 'FOO:.*\n\n'
>
> The chunk of text I am attempting to locate is a line beginning with
> "FOO:", followed by an unknown number of lines, terminating with a
> blank line. Clearly th
Regex questions seem to be rather resistant to googling.
My regex currently looks like - 'FOO:.*\n\n'
The chunk of text I am attempting to locate is a line beginning with
"FOO:", followed by an unknown number of lines, terminating with a
blank line. Clearly the ".*" phrase does not match the sing
Steven Bethard wrote:
Kent Johnson wrote:
for line in raw_data:
if line.startswith('RelevantInfo1'):
info1 = raw_data.next().strip()
elif line.startswith('RelevantInfo2'):
info2 = raw_data.next().strip()
elif line.startswith('RelevantInfo3'):
info3 = raw_data.nex
Kent Johnson wrote:
for line in raw_data:
if line.startswith('RelevantInfo1'):
info1 = raw_data.next().strip()
elif line.startswith('RelevantInfo2'):
info2 = raw_data.next().strip()
elif line.startswith('RelevantInfo3'):
info3 = raw_data.next().strip()
sc
On Thu, 3 Mar 2005 12:26:37 -0800, James Stroud <[EMAIL PROTECTED]> wrote:
> Have a look at "martel", part of biopython. The world of bioinformatics is
> filled with files with structure like this.
>
> http://www.biopython.org/docs/api/public/Martel-module.html
>
> James
Thanks for the link. Stev
On Thu, 03 Mar 2005 16:25:39 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Here is another attempt. I'm still not sure I understand what form you want
> the data in. I made a
> dict -> dict -> list structure so if you lookup e.g. scores['10/11/04']['60']
> you get a list of all
> the Relevan
On Thu, 03 Mar 2005 13:45:31 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote:
>
> I think if you use the non-greedy .*? instead of the greedy .*, you'll
> get this behavior. For example:
>
> py> s = """\
> ... Gibberish
> ... 53
> ... MoreGarbage
> [snip a whole bunch of stuff]
> ... RelevantInfo
Here is another attempt. I'm still not sure I understand what form you want the data in. I made a
dict -> dict -> list structure so if you lookup e.g. scores['10/11/04']['60'] you get a list of all
the RelevantInfo2 values for Relevant1='10/11/04' and Relevant2='60'.
The parser is a simple-minde
Yatima wrote:
On Thu, 03 Mar 2005 09:54:02 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote:
A possible solution, using the re module:
py> s = """\
... Gibberish
... 53
... MoreGarbage
... 12
... RelevantInfo1
... 10/10/04
... NothingImportant
... ThisDoesNotMatter
... 44
... RelevantInfo2
... 22
..
I found the original paper for Martel:
http://www.dalkescientific.com/Martel/ipc9/
On Thursday 03 March 2005 12:26 pm, James Stroud wrote:
> Have a look at "martel", part of biopython. The world of bioinformatics is
> filled with files with structure like this.
>
> http://www.biopython.org/docs/a
On Thu, 03 Mar 2005 07:14:50 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> Here is a way to create a list of [RelevantInfo, value] pairs:
> import cStringIO
>
> raw_data = '''Gibberish
> 53
> MoreGarbage
> 12
> RelevantInfo1
> 10/10/04
> NothingImportant
> ThisDoesNotMatter
> 44
> RelevantInfo
Have a look at "martel", part of biopython. The world of bioinformatics is
filled with files with structure like this.
http://www.biopython.org/docs/api/public/Martel-module.html
James
On Thursday 03 March 2005 12:03 pm, Yatima wrote:
> On Thu, 03 Mar 2005 09:54:02 -0700, Steven Bethard
<[EMAI
On Thu, 03 Mar 2005 09:54:02 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote:
>
> A possible solution, using the re module:
>
> py> s = """\
> ... Gibberish
> ... 53
> ... MoreGarbage
> ... 12
> ... RelevantInfo1
> ... 10/10/04
> ... NothingImportant
> ... ThisDoesNotMatter
> ... 44
> ... RelevantI
Yatima wrote:
Hey Folks,
I've got some info in a bunch of files that kind of looks like so:
Gibberish
53
MoreGarbage
12
RelevantInfo1
10/10/04
NothingImportant
ThisDoesNotMatter
44
RelevantInfo2
22
BlahBlah
343
RelevantInfo3
23
Hubris
Crap
34
and so on...
Anyhow, these "fields" repeat several times
1 - 100 of 102 matches
Mail list logo