Re: Python Regex Question

2008-10-29 Thread Terry Reedy
MalteseUnderdog wrote: Hi there I just started python (but this question isn't that trivial since I couldn't find it in google :) ) I have the following text file entries (simplified) start #frag 1 start x=Dog # frag 1 end stop start# frag 2 start x=Cat # frag 2 end stop start #fra

Re: Python Regex Question

2008-10-29 Thread Arnaud Delobelle
On Oct 29, 7:01 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > I need a regex expression which returns the start to the x=ANIMAL for > > only the x=Dog fragments so all my entries should be start ... > > (something here) ... x=Dog .  So I am really interested in fragments 1 > > and 3 only. > > > My i

Re: Python Regex Question

2008-10-29 Thread Tim Chase
I need a regex expression which returns the start to the x=ANIMAL for only the x=Dog fragments so all my entries should be start ... (something here) ... x=Dog . So I am really interested in fragments 1 and 3 only. My idea (primitive) ^start.*?x=Dog doesn't work because clearly it would return r

Python Regex Question

2008-10-29 Thread MalteseUnderdog
Hi there I just started python (but this question isn't that trivial since I couldn't find it in google :) ) I have the following text file entries (simplified) start #frag 1 start x=Dog # frag 1 end stop start# frag 2 start x=Cat # frag 2 end stop start #frag 3 start x=Dog #frag 3

Re: Python regex question

2008-08-15 Thread Tim N. van der Leeuw
#x27;t fit in the parser-engine I had and I was close to making a release. But still: thanks! --Tim -- View this message in context: http://www.nabble.com/Python-regex-question-tp17773487p18997385.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python regex question

2008-06-11 Thread Gerhard Häring
Tim van der Leeuw wrote: Hi, I'm trying to create a regular expression for matching some particular XML strings. I want to extract the contents of a particular XML tag, only if it follows one tag, but not follows another tag. Complicating this, is that there can be any number of other tags in

Python regex question

2008-06-11 Thread Tim van der Leeuw
Hi, I'm trying to create a regular expression for matching some particular XML strings. I want to extract the contents of a particular XML tag, only if it follows one tag, but not follows another tag. Complicating this, is that there can be any number of other tags in between. So basically, my re

Re: python/regex question... hope someone can help

2007-12-09 Thread Gabriel Genellina
En Sun, 09 Dec 2007 16:45:53 -0300, charonzen <[EMAIL PROTECTED]> escribió: >> [John Machin] Another suggestion is to ensure that the job >> specification is not >> overly simplified. How did you parse the text into "words" in the >> prior exercise that produced the list of bigrams? Won't you

Re: python/regex question... hope someone can help

2007-12-09 Thread charonzen
> Another suggestion is to ensure that the job specification is not > overly simplified. How did you parse the text into "words" in the > prior exercise that produced the list of bigrams? Won't you need to > use the same parsing method in the current exercise of tagging the > bigrams with an under

Re: python/regex question... hope someone can help

2007-12-09 Thread John Machin
On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: The following *may* come close to doing what your revised spec requires: import re def ch_replace2(alist, text): for bigram in alist: pattern = r'\b' + bigram.replace('_', ' ') + r'\b' text = re.sub(pattern, bigram, text)

Re: python/regex question... hope someone can help

2007-12-09 Thread John Machin
On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: > I have a list of strings. These strings are previously selected > bigrams with underscores between them ('and_the', 'nothing_given', and > so on). I need to write a regex that will read another text string > that this list was derived from

python/regex question... hope someone can help

2007-12-08 Thread charonzen
I have a list of strings. These strings are previously selected bigrams with underscores between them ('and_the', 'nothing_given', and so on). I need to write a regex that will read another text string that this list was derived from and replace selections in this text string with those from my l

Re: Python Regex Question

2007-09-21 Thread David
> re.search(expr, string) compiles and searches every time. This can > potentially be more expensive in calculating power. especially if you > have to use the expression a lot of times. The re module-level helper functions cache expressions and their compiled form in a dict. They are only compiled

Re: Python Regex Question

2007-09-21 Thread Ivo
crybaby wrote: > On Sep 20, 4:12 pm, Tobiah <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> I need to extract the number on each >> i.e 49.950 from the following: >>>  49.950  >>> The actual number between:  49.950  can be any number of >>> digits before decimal and after decimal. >>>  #

Re: Python Regex Question

2007-09-20 Thread crybaby
On Sep 20, 4:12 pm, Tobiah <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I need to extract the number on each > > i.e 49.950 from the following: > > >  49.950  > > > The actual number between:  49.950  can be any number of > > digits before decimal and after decimal. > > >  ##.

Re: Python Regex Question

2007-09-20 Thread Gerardo Herzig
[EMAIL PROTECTED] wrote: >I need to extract the number on each >i.e 49.950 from the following: > > 49.950  > >The actual number between:  49.950  can be any number of >digits before decimal and after decimal. > > ##.  > >How can I just extract the real/integer number using regex? > > >

Re: Python Regex Question

2007-09-20 Thread Tobiah
[EMAIL PROTECTED] wrote: > I need to extract the number on each > i.e 49.950 from the following: > >  49.950  > > The actual number between:  49.950  can be any number of > digits before decimal and after decimal. > >  ##.  > > How can I just extract the real/integer number using rege

Python Regex Question

2007-09-20 Thread joemystery123
I need to extract the number on each  49.950  The actual number between:  49.950  can be any number of digits before decimal and after decimal.  ##.  How can I just extract the real/integer number using regex? -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Python REGEX Question

2007-05-12 Thread James T. Dennis
johnny <[EMAIL PROTECTED]> wrote: > I need to get the content inside the bracket. > eg. some characters before bracket (3.12345). > I need to get whatever inside the (), in this case 3.12345. > How do you do this with python regular expression? I'm going to presume that you mean something like:

Re: Simple Python REGEX Question

2007-05-11 Thread Steven D'Aprano
On Fri, 11 May 2007 08:54:31 -0700, johnny wrote: > I need to get the content inside the bracket. > > eg. some characters before bracket (3.12345). > > I need to get whatever inside the (), in this case 3.12345. > > How do you do this with python regular expression? Why would you bother? If yo

Re: Simple Python REGEX Question

2007-05-11 Thread John Machin
On May 12, 2:21 am, Gary Herron <[EMAIL PROTECTED]> wrote: > johnny wrote: > > I need to get the content inside the bracket. > > > eg. some characters before bracket (3.12345). > > > I need to get whatever inside the (), in this case 3.12345. > > > How do you do this with python regular expression?

Re: Simple Python REGEX Question

2007-05-11 Thread Gary Herron
johnny wrote: > I need to get the content inside the bracket. > > eg. some characters before bracket (3.12345). > > I need to get whatever inside the (), in this case 3.12345. > > How do you do this with python regular expression? > >>> import re >>> x = re.search("[0-9.]+", "(3.12345)") >>> pr

Simple Python REGEX Question

2007-05-11 Thread johnny
I need to get the content inside the bracket. eg. some characters before bracket (3.12345). I need to get whatever inside the (), in this case 3.12345. How do you do this with python regular expression? -- http://mail.python.org/mailman/listinfo/python-list