Re: [Tutor] regex help

2009-02-23 Thread spir
Le Mon, 23 Feb 2009 06:45:23 -0500, Kent Johnson s'exprima ainsi: > On Sun, Feb 22, 2009 at 10:49 PM, ish_ling wrote: > > I have a string: > > > >'a b c h' > > > > I would like a regex to recursively match all alpha letters that are > > between . That is, I would like the following list of >

Re: [Tutor] regex help

2009-02-23 Thread Kent Johnson
On Sun, Feb 22, 2009 at 10:49 PM, ish_ling wrote: > I have a string: > >'a b c h' > > I would like a regex to recursively match all alpha letters that are between > . That is, I would like the following list of matches: > >['d', 'e', 'f', 'i', 'j'] > > I do not want the 'g' or the 'k' mat

Re: [Tutor] regex help

2009-02-23 Thread Paul McGuire
I second Alan G's appreciation for a well-thought-through and well-conveyed description of your text processing task. (Is "Alan G" his gangsta name, I wonder?) This pyparsing snippet may point you to some easier-to-follow code, especially once you go beyond the immediate task and do more exhausti

Re: [Tutor] regex help

2009-02-23 Thread Alan Gauld
"ish_ling" wrote 'a b c h' I would like a regex to Congratulations on a cclear explanation of what you want. With regex questions that is half the battle. I have figured out how to do this in a multiple-step process And there's nothing much wrong with multi step. with re.findall()

[Tutor] regex help

2009-02-22 Thread ish_ling
I have a string: 'a b c h' I would like a regex to recursively match all alpha letters that are between . That is, I would like the following list of matches: ['d', 'e', 'f', 'i', 'j'] I do not want the 'g' or the 'k' matched. I have figured out how to do this in a multiple-step proce

Re: [Tutor] Regex help

2006-08-28 Thread Kent Johnson
William O'Higgins Witteman wrote: > On Mon, Aug 28, 2006 at 11:36:18AM -0400, Kent Johnson wrote: > >> William O'Higgins Witteman wrote: >> >>> Thank you for this. The problem is apparently not my syntax, but >>> something else. Here is a pared-down snippet of what I'm doing: >>> >>> In [1

Re: [Tutor] Regex help

2006-08-28 Thread William O'Higgins Witteman
On Mon, Aug 28, 2006 at 11:36:18AM -0400, Kent Johnson wrote: >William O'Higgins Witteman wrote: >> Thank you for this. The problem is apparently not my syntax, but >> something else. Here is a pared-down snippet of what I'm doing: >> >> In [1]: import re >> >> In [2]: pat = re.compile(''' >>

Re: [Tutor] Regex help

2006-08-28 Thread Kent Johnson
William O'Higgins Witteman wrote: > Thank you for this. The problem is apparently not my syntax, but > something else. Here is a pared-down snippet of what I'm doing: > > In [1]: import re > > In [2]: pat = re.compile(''' > ...:copy of > ...:| > ...:admin > ...

Re: [Tutor] Regex help

2006-08-28 Thread William O'Higgins Witteman
On Sat, Aug 26, 2006 at 09:45:04AM -0400, Kent Johnson wrote: >William O'Higgins Witteman wrote: >> I want a case-insensitive, verbose pattern. I have a long-ish list of >> match criteria (about a dozen distinct cases), which should be all "or", >> so I won't need to be clever with precedence. > >

Re: [Tutor] Regex help

2006-08-28 Thread Michael Janssen
On 8/26/06, William O'Higgins Witteman <[EMAIL PROTECTED]> wrote: > I want a case-insensitive, verbose pattern. I have a long-ish list of > match criteria (about a dozen distinct cases), which should be all "or", > so I won't need to be clever with precedence. BTW I find it easier not to use re.

Re: [Tutor] Regex help

2006-08-26 Thread Kent Johnson
William O'Higgins Witteman wrote: > Hello all, > > I've been looking for an example of the regex I need, and so far, I > haven't found anything. Here's what I need: > > I want a case-insensitive, verbose pattern. I have a long-ish list of > match criteria (about a dozen distinct cases), which sho

[Tutor] Regex help

2006-08-26 Thread William O'Higgins Witteman
Hello all, I've been looking for an example of the regex I need, and so far, I haven't found anything. Here's what I need: I want a case-insensitive, verbose pattern. I have a long-ish list of match criteria (about a dozen distinct cases), which should be all "or", so I won't need to be clever

Re: [Tutor] Regex help

2005-10-10 Thread Bill Burns
> On Mon, 10 Oct 2005, Bill Burns wrote: > > >>I'm looking to get the size (width, length) of a PDF file. > > Hi Bill, > > Just as a side note: you may want to look into using the 'pdfinfo' utility > that comes as part of the xpdf package: > > http://www.foolabs.com/xpdf/ > > For exampl

Re: [Tutor] Regex help

2005-10-10 Thread Danny Yoo
On Mon, 10 Oct 2005, Bill Burns wrote: > I'm looking to get the size (width, length) of a PDF file. Hi Bill, Just as a side note: you may want to look into using the 'pdfinfo' utility that comes as part of the xpdf package: http://www.foolabs.com/xpdf/ For example:

Re: [Tutor] Regex help

2005-10-10 Thread Bill Burns
[Andrew] > If the format is consistent enough, you might get away with something like: > > >>> p = re.compile('MediaBox \[ ?\d+ \d+ (\d+) (\d+) ?\]') > >>> print p.search(s).groups() > ('612', '792') > > The important bits being: ? means "0 or 1 occurences", and you can use > parentheses to

Re: [Tutor] Regex help

2005-10-10 Thread Bill Burns
>> I'm looking to get the size (width, length) of a PDF file. Every pdf >> file has a 'tag' (in the file) that looks similar to this >> >> Example #1 >> MediaBox [0 0 612 792] >> >> or this >> >> Example #2 >> MediaBox [ 0 0 612 792 ] >> >> I figured a regex might be a good way to get this data but

Re: [Tutor] Regex help

2005-10-09 Thread Andrew P
If the format is consistent enough,  you might get away with something like: >>> p = re.compile('MediaBox \[ ?\d+ \d+ (\d+) (\d+) ?\]') >>> print p.search(s).groups() ('612', '792') The important bits being:  ? means "0 or 1 occurences", and you can use parentheses to group matches, and they get

Re: [Tutor] Regex help

2005-10-09 Thread bob
At 09:10 PM 10/9/2005, Bill Burns wrote: >I'm looking to get the size (width, length) of a PDF file. Every pdf >file has a 'tag' (in the file) that looks similar to this > >Example #1 >MediaBox [0 0 612 792] > >or this > >Example #2 >MediaBox [ 0 0 612 792 ] > >I figured a regex might be a good way

[Tutor] Regex help

2005-10-09 Thread Bill Burns
I'm looking to get the size (width, length) of a PDF file. Every pdf file has a 'tag' (in the file) that looks similar to this Example #1 MediaBox [0 0 612 792] or this Example #2 MediaBox [ 0 0 612 792 ] I figured a regex might be a good way to get this data but the whitespace (or no whitespac