Re: a regex question

2019-10-25 Thread dieter
Maggie Q Roth writes: > There are two primary types of lines in the log: > > 60.191.38.xx/ > 42.120.161.xx /archives/1005 > > I know how to write regex to match each line, but don't get the good result > with one regex to match both lines. > > Can you help? When I look at these

Re: a regex question

2019-10-25 Thread Antoon Pardon
On 25/10/19 12:22, Maggie Q Roth wrote: > Hello > > There are two primary types of lines in the log: > > 60.191.38.xx/ > 42.120.161.xx /archives/1005 > > I know how to write regex to match each line, but don't get the good result > with one regex to match both lines. Could you

Re: a regex question

2019-10-25 Thread Brian Oney via Python-list
On October 25, 2019 12:22:44 PM GMT+02:00, Maggie Q Roth wrote: >Hello > >There are two primary types of lines in the log: > >60.191.38.xx/ >42.120.161.xx /archives/1005 > >I know how to write regex to match each line, but don't get the good >result >with one regex to match both

a regex question

2019-10-25 Thread Maggie Q Roth
Hello There are two primary types of lines in the log: 60.191.38.xx/ 42.120.161.xx /archives/1005 I know how to write regex to match each line, but don't get the good result with one regex to match both lines. Can you help? Thanks, Maggie --

Re: Regex Question

2012-08-18 Thread Mark Lawrence
On 18/08/2012 06:42, Chris Angelico wrote: On Sat, Aug 18, 2012 at 2:41 PM, Frank Koshti frank.kos...@gmail.com wrote: Hi, I'm new to regular expressions. I want to be able to match for tokens with all their properties in the following examples. I would appreciate some direction on how to

Re: Regex Question

2012-08-18 Thread Roy Smith
In article 385e732e-1c02-4dd0-ab12-b92890bbe...@o3g2000yqp.googlegroups.com, Frank Koshti frank.kos...@gmail.com wrote: I'm new to regular expressions. I want to be able to match for tokens with all their properties in the following examples. I would appreciate some direction on how to

Re: Regex Question

2012-08-18 Thread Steven D'Aprano
On Fri, 17 Aug 2012 21:41:07 -0700, Frank Koshti wrote: Hi, I'm new to regular expressions. I want to be able to match for tokens with all their properties in the following examples. I would appreciate some direction on how to proceed. Others have already given you excellent advice to NOT

Re: Regex Question

2012-08-18 Thread Frank Koshti
I think the point was missed. I don't want to use an XML parser. The point is to pick up those tokens, and yes I've done my share of RTFM. This is what I've come up with: '\$\w*\(?.*?\)' Which doesn't work well on the above example, which is partly why I reached out to the group. Can anyone help

Re: Regex Question

2012-08-18 Thread Frank Koshti
Hey Steven, Thank you for the detailed (and well-written) tutorial on this very issue. I actually learned a few things! Though, I still have unresolved questions. The reason I don't want to use an XML parser is because the tokens are not always placed in HTML, and even in HTML, they may appear

Re: Regex Question

2012-08-18 Thread Peter Otten
Frank Koshti wrote: I need to match, process and replace $foo(x=3), knowing that (x=3) is optional, and the token might appear simply as $foo. To do this, I decided to use: re.compile('\$\w*\(?.*?\)').findall(mystring) the issue with this is it doesn't match $foo by itself, and

Re: Regex Question

2012-08-18 Thread Vlastimil Brom
2012/8/18 Frank Koshti frank.kos...@gmail.com: Hey Steven, Thank you for the detailed (and well-written) tutorial on this very issue. I actually learned a few things! Though, I still have unresolved questions. The reason I don't want to use an XML parser is because the tokens are not

Re: Regex Question

2012-08-18 Thread Frank Koshti
On Aug 18, 11:48 am, Peter Otten __pete...@web.de wrote: Frank Koshti wrote: I need to match, process and replace $foo(x=3), knowing that (x=3) is optional, and the token might appear simply as $foo. To do this, I decided to use: re.compile('\$\w*\(?.*?\)').findall(mystring) the

Re: Regex Question

2012-08-18 Thread Jussi Piitulainen
Frank Koshti writes: not always placed in HTML, and even in HTML, they may appear in strange places, such as h1 $foo(x=3)Hello/h1. My specific issue is I need to match, process and replace $foo(x=3), knowing that (x=3) is optional, and the token might appear simply as $foo. To do this, I

Re: Regex Question

2012-08-18 Thread python
Steven, Well done!!! Regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Regex Question

2012-08-18 Thread Frank Koshti
On Aug 18, 12:22 pm, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: Frank Koshti writes: not always placed in HTML, and even in HTML, they may appear in strange places, such as h1 $foo(x=3)Hello/h1. My specific issue is I need to match, process and replace $foo(x=3), knowing that

Re: Regex Question

2012-08-17 Thread Chris Angelico
On Sat, Aug 18, 2012 at 2:41 PM, Frank Koshti frank.kos...@gmail.com wrote: Hi, I'm new to regular expressions. I want to be able to match for tokens with all their properties in the following examples. I would appreciate some direction on how to proceed. h1@foo1/h1 p@foo2()/p

Re: regex question

2011-07-29 Thread Thomas Jollans
On 29/07/11 16:53, rusi wrote: Can someone throw some light on this anomalous behavior? import re r = re.search('a(b+)', 'ababbaaab') r.group(1) 'b' r.group(0) 'ab' r.group(2) Traceback (most recent call last): File stdin, line 1, in module IndexError: no such group

Re: regex question

2011-07-29 Thread MRAB
On 29/07/2011 16:45, Thomas Jollans wrote: On 29/07/11 16:53, rusi wrote: Can someone throw some light on this anomalous behavior? import re r = re.search('a(b+)', 'ababbaaab') r.group(1) 'b' r.group(0) 'ab' r.group(2) Traceback (most recent call last): File stdin, line 1,

Re: regex question

2011-07-29 Thread Rustom Mody
MRAB wrote: findall returns a list of tuples (what the groups captured) if there is more than 1 group, or a list of strings (what the group captured) if there is 1 group, or a list of strings (what the regex matched) if there are no groups. Thanks. It would be good to put this in the manual

Re: regex question

2011-07-29 Thread Thomas Jollans
On 29/07/11 19:52, Rustom Mody wrote: MRAB wrote: findall returns a list of tuples (what the groups captured) if there is more than 1 group, or a list of strings (what the group captured) if there is 1 group, or a list of strings (what the regex matched) if there are no groups. Thanks.

Re: regex question on .findall and \b

2009-07-06 Thread Ethan Furman
Many thanks to all who replied! And, yes, I will *definitely* use raw strings from now on. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: regex question on .findall and \b

2009-07-02 Thread Tim Chase
Ethan Furman wrote: Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type copyright, credits or license for more information. IPython 0.9.1 -- An enhanced Interactive Python. In [161]: re.findall('\d+','this is test

Re: regex question on .findall and \b

2009-07-02 Thread Sjoerd Mullender
On 2009-07-02 18:38, Ethan Furman wrote: Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type copyright, credits or license for more information. IPython 0.9.1 -- An enhanced Interactive Python. In [161]:

Re: regex question on .findall and \b

2009-07-02 Thread Nobody
On Thu, 02 Jul 2009 09:38:56 -0700, Ethan Furman wrote: Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type copyright, credits or license for more information. IPython 0.9.1 -- An enhanced Interactive Python.

Re: regex question on .findall and \b

2009-07-02 Thread Ethan Furman
Ethan Furman wrote: Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type copyright, credits or license for more information. IPython 0.9.1 -- An enhanced Interactive Python. In [161]: re.findall('\d+','this is

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-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

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 idea

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

Re: Python regex question

2008-08-15 Thread Tim N. van der Leeuw
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: regex question

2008-08-06 Thread Tobiah
On Tue, 05 Aug 2008 15:55:46 +0100, Fred Mangusta wrote: Chris wrote: Doesn't work for his use case as he wants to keep periods marking the end of a sentence. Doesn't it? The period has to be surrounded by digits in the example solution, so wouldn't periods followed by a space (end of

Re: regex question

2008-08-05 Thread Marc 'BlackJack' Rintsch
On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote: In other words I'd like to replace all the instances of a '.' character with something (say nothing at all) when the '.' is representing a decimal separator. E.g. 500.675 500675 but also 1.000.456.344 1000456344

Re: regex question

2008-08-05 Thread Alexei Zankevich
No, there is a bad way - because of the example doesn't solve arbitrary amount of number.number.. blocks. But the python regexp engine supports for lookahead (?=pattern) and lookbehind (?=pattern). In those cases patterns are not included into the replaced sequence of characters:

Re: regex question

2008-08-05 Thread Jeff
On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote: In other words I'd like to replace all the instances of a '.' character with something (say nothing at all) when the '.' is representing a decimal separator. E.g.

Re: regex question

2008-08-05 Thread Alexei Zankevich
=) Indeed. But it will replace all dots including ordinary strings instead of numbers only. On Tue, Aug 5, 2008 at 3:23 PM, Jeff [EMAIL PROTECTED] wrote: On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote: In other

Re: regex question

2008-08-05 Thread Chris
On Aug 5, 2:23 pm, Jeff [EMAIL PROTECTED] wrote: On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote: In other words I'd like to replace all the instances of a '.' character with something (say nothing at all)

Re: regex question

2008-08-05 Thread Fred Mangusta
Chris wrote: Doesn't work for his use case as he wants to keep periods marking the end of a sentence. Exactly. Thanks to all of you anyway, now I have a better understanding on how to go on :) F. -- http://mail.python.org/mailman/listinfo/python-list

Re: regex question

2008-08-05 Thread MRAB
On Aug 5, 11:39 am, Fred Mangusta [EMAIL PROTECTED] wrote: Hi, I would like to delete all the instances of a '.' into a number. In other words I'd like to replace all the instances of a '.' character with something (say nothing at all) when the '.' is representing a decimal separator. E.g.

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: 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

Re: regex question

2008-02-13 Thread Wanja Chresta
Hey Mathieu Due to word wrap I'm not sure what you want to do. What result do you expect? I get: print m.groups() ('0021', 'xx0A', 'Siemens: Thorax/Multix FD Lab Settings Auto Window Width ', ' ', 'SL', '1') But only when I insert a space in the 3rd char group (I'm not sure if your original

Re: regex question

2008-02-13 Thread grflanagan
On Feb 13, 1:53 pm, mathieu [EMAIL PROTECTED] wrote: I do not understand what is wrong with the following regex expression. I clearly mark that the separator in between group 3 and group 4 should contain at least 2 white space, but group 3 is actually reading 3 +4 Thanks -Mathieu import

Re: regex question

2008-02-13 Thread bearophileHUGS
mathieu, stop writing complex REs like obfuscated toys, use the re.VERBOSE flag and split that RE into several commented and *indented* lines (indented just like Python code), the indentation level has to be used to denote nesting. With that you may be able to solve the problem by yourself. If

Re: regex question

2008-02-13 Thread Paul McGuire
On Feb 13, 6:53 am, mathieu [EMAIL PROTECTED] wrote: I do not understand what is wrong with the following regex expression. I clearly mark that the separator in between group 3 and group 4 should contain at least 2 white space, but group 3 is actually reading 3 +4 Thanks -Mathieu import

Re: a newbie regex question

2008-01-25 Thread Max Erickson
Dotan Cohen [EMAIL PROTECTED] wrote: Maybe you mean: for match in re.finditer(r'\([A-Z].+[a-z])\', contents): Note the last backslash was in the wrong place. The location of the backslash in the orignal reply is correct, it is there to escape the closing paren, which is a special character:

Re: a newbie regex question

2008-01-25 Thread Dotan Cohen
On 24/01/2008, Jonathan Gardner [EMAIL PROTECTED] wrote: On Jan 24, 12:14 pm, Shoryuken [EMAIL PROTECTED] wrote: Given a regular expression pattern, for example, \([A-Z].+[a-z]\), print out all strings that match the pattern in a file Anyone tell me a way to do it? I know it's easy, but

a newbie regex question

2008-01-24 Thread Shoryuken
Given a regular expression pattern, for example, \([A-Z].+[a-z]\), print out all strings that match the pattern in a file Anyone tell me a way to do it? I know it's easy, but i'm completely new to python thanks alot -- http://mail.python.org/mailman/listinfo/python-list

Re: a newbie regex question

2008-01-24 Thread Jonathan Gardner
On Jan 24, 12:14 pm, Shoryuken [EMAIL PROTECTED] wrote: Given a regular expression pattern, for example, \([A-Z].+[a-z]\), print out all strings that match the pattern in a file Anyone tell me a way to do it? I know it's easy, but i'm completely new to python thanks alot You may want to

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 and

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 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 underscore?

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 need to

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

Re: RegEx question

2007-10-04 Thread Robert Dailey
It should also match: @param[out] state Some description of this variable On 10/4/07, Robert Dailey [EMAIL PROTECTED] wrote: Hi, The following regex (Not including the end quotes): @param\[in|out\] \w+ Should match any of the following: @param[in] variable @param[out] state

Re: RegEx question

2007-10-04 Thread Adam Lanier
On Thu, 2007-10-04 at 10:58 -0500, Robert Dailey wrote: It should also match: @param[out] state Some description of this variable On 10/4/07, Robert Dailey [EMAIL PROTECTED] wrote: Hi, The following regex (Not including the end quotes):

Re: RegEx question

2007-10-04 Thread J. Clifford Dyer
-0500, Robert Dailey wrote regarding Re: RegEx question: On 10/4/07, Adam Lanier [EMAIL PROTECTED] wrote: try @param\[(in|out)\] \w+ This didn't work either :( The tool using this regular expression (Comment Reflower for VS2005) May be broken... References 1

Re: RegEx question

2007-10-04 Thread Robert Dailey
On 10/4/07, Adam Lanier [EMAIL PROTECTED] wrote: try @param\[(in|out)\] \w+ This didn't work either :( The tool using this regular expression (Comment Reflower for VS2005) May be broken... -- http://mail.python.org/mailman/listinfo/python-list

Re: RegEx question

2007-10-04 Thread Robert Dailey
On 10/4/07, J. Clifford Dyer [EMAIL PROTECTED] wrote: You *are* talking about python regular expressions, right? There are a number of different dialects. Also, there could be issues with the quoting method (are you using raw strings?) The more specific you can get, the more we can help

Re: RegEx question

2007-10-04 Thread Jerry Hill
As far as the dialect, I can't be sure. I am unable to find documentation for Comment Reflower and thus cannot figure out what type of regex it is using. What exactly do you mean by your question, are you using raw strings?. Thanks for your response and I apologize for the lack of detail.

Re: RegEx question

2007-10-04 Thread Manu Hack
On 10/4/07, Robert Dailey [EMAIL PROTECTED] wrote: On 10/4/07, Adam Lanier [EMAIL PROTECTED] wrote: try @param\[(in|out)\] \w+ This didn't work either :( The tool using this regular expression (Comment Reflower for VS2005) May be broken... --

Re: RegEx question

2007-10-04 Thread Tim Chase
[sigh...replying to my own post] However, things to try: - sometimes the grouping parens need to be escaped with \ - sometimes \w isn't a valid character class, so use the long-hand variant of something like [a-zA-Z0-9_]] - sometimes the + is escaped with a \ - if you don't use raw

Re: RegEx question

2007-10-04 Thread Robert Dailey
I am not a regex expert, I simply assumed regex was standardized to follow specific guidelines. I also made the assumption that this was a good place to pose the question since regular expressions are a feature of Python. The question concerned regular expressions in general, not really the

Re: RegEx question

2007-10-04 Thread Tim Chase
try @param\[(in|out)\] \w+ This didn't work either :( The tool using this regular expression (Comment Reflower for VS2005) May be broken... How about @param\[[i|o][n|u]t*\]\w+ ? ...if you want to accept patterns like @param[iutt]xxx ... The regexp at the top (Adam's

Re: RegEx question

2007-10-04 Thread John Masters
their own 'extensions'. I also made the assumption that this was a good place to pose the question since regular expressions are a feature of Python. The best place to pose a regex question is in the sphere of usage, i.e. Perl regexes differ hugely in implementation from OO langs like Python

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 td tags from a html file. i.e 49.950 from the following: td align=right width=80font size=2 face=New Times Roman,Times,Serifnbsp;49.950nbsp;/font/td The actual

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

Python Regex Question

2007-09-20 Thread joemystery123
I need to extract the number on each td tags from a html file. i.e 49.950 from the following: td align=right width=80font size=2 face=New Times Roman,Times,Serifnbsp;49.950nbsp;/font/td The actual number between: nbsp;49.950nbsp; can be any number of digits before decimal and after decimal. td

Re: Python Regex Question

2007-09-20 Thread Tobiah
[EMAIL PROTECTED] wrote: I need to extract the number on each td tags from a html file. i.e 49.950 from the following: td align=right width=80font size=2 face=New Times Roman,Times,Serifnbsp;49.950nbsp;/font/td The actual number between: nbsp;49.950nbsp; can be any number of digits

Re: Python Regex Question

2007-09-20 Thread Gerardo Herzig
[EMAIL PROTECTED] wrote: I need to extract the number on each td tags from a html file. i.e 49.950 from the following: td align=right width=80font size=2 face=New Times Roman,Times,Serifnbsp;49.950nbsp;/font/td The actual number between: nbsp;49.950nbsp; can be any number of digits before

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 td tags from a html file. i.e 49.950 from the following: td align=right width=80font size=2 face=New Times Roman,Times,Serifnbsp;49.950nbsp;/font/td The actual number

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 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)) print x.group(0)

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

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? import re

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 you know

Re: regex question

2007-04-29 Thread proctor
On Apr 27, 8:26 am, Michael Hoffman [EMAIL PROTECTED] wrote: proctorwrote: On Apr 27, 1:33 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am,proctor[EMAIL PROTECTED] wrote: rx_test = re.compile('/x([^x])*x/') s = '/xabcx/' if rx_test.findall(s): print

Re: regex question

2007-04-27 Thread Josiah Carlson
proctor wrote: i have a regex: rx_test = re.compile('/x([^x])*x/') You probably want... rx_test = re.compile('/x([^x]*)x/') - Josiah -- http://mail.python.org/mailman/listinfo/python-list

Re: regex question

2007-04-27 Thread Paul McGuire
On Apr 27, 1:33 am, proctor [EMAIL PROTECTED] wrote: hello, i have a regex: rx_test = re.compile('/x([^x])*x/') which is part of this test program: import re rx_test = re.compile('/x([^x])*x/') s = '/xabcx/' if rx_test.findall(s): print rx_test.findall(s)

Re: regex question

2007-04-27 Thread proctor
On Apr 27, 1:33 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, proctor [EMAIL PROTECTED] wrote: hello, i have a regex: rx_test = re.compile('/x([^x])*x/') which is part of this test program: import re rx_test = re.compile('/x([^x])*x/') s =

Re: regex question

2007-04-27 Thread Michael Hoffman
proctor wrote: On Apr 27, 1:33 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, proctor [EMAIL PROTECTED] wrote: rx_test = re.compile('/x([^x])*x/') s = '/xabcx/' if rx_test.findall(s): print rx_test.findall(s) i expect the output to be ['abc'] however it

Re: regex question

2007-04-27 Thread Duncan Booth
proctor [EMAIL PROTECTED] wrote: so my question remains, why doesn't the star quantifier seem to grab all the data. isn't findall() intended to return all matches? i would expect either 'abc' or 'a', 'b', 'c' or at least just 'a' (because that would be the first match). why does it give

Re: regex question

2007-04-27 Thread Paul McGuire
On Apr 27, 9:10 am, proctor [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, proctor [EMAIL PROTECTED] wrote: hello, i have a regex: rx_test = re.compile('/x([^x])*x/') which is part of this test program:

Re: regex question

2007-04-27 Thread proctor
On Apr 27, 8:26 am, Michael Hoffman [EMAIL PROTECTED] wrote: proctor wrote: On Apr 27, 1:33 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, proctor [EMAIL PROTECTED] wrote: rx_test = re.compile('/x([^x])*x/') s = '/xabcx/' if rx_test.findall(s): print

Re: regex question

2007-04-27 Thread proctor
On Apr 27, 8:37 am, Duncan Booth [EMAIL PROTECTED] wrote: proctor [EMAIL PROTECTED] wrote: so my question remains, why doesn't the star quantifier seem to grab all the data. isn't findall() intended to return all matches? i would expect either 'abc' or 'a', 'b', 'c' or at least just 'a'

Re: regex question

2007-04-27 Thread Duncan Booth
proctor [EMAIL PROTECTED] wrote: re.findall('(.)*', 'abc') ['c', ''] thank you this is interesting. in the second example, where does the 'nothingness' match, at the end? why does the regex 'run again' when it has already matched everything? and if it reports an empty match along with

Re: regex question

2007-04-27 Thread proctor
On Apr 27, 8:50 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 9:10 am, proctor [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 27, 1:33 am, proctor [EMAIL PROTECTED] wrote: hello, i have a regex: rx_test =

Re: Regex Question

2007-01-18 Thread Bill Mill
Gabriel Genellina wrote: At Tuesday 16/1/2007 16:36, Bill Mill wrote: py import re py rgx = re.compile('1?') py rgx.search('a1').groups() (None,) py rgx = re.compile('(1)+') py rgx.search('a1').groups() But shouldn't the ? be greedy, and thus prefer the one match to the

Re: Regex Question

2007-01-17 Thread Gabriel Genellina
At Tuesday 16/1/2007 16:36, Bill Mill wrote: py import re py rgx = re.compile('1?') py rgx.search('a1').groups() (None,) py rgx = re.compile('(1)+') py rgx.search('a1').groups() But shouldn't the ? be greedy, and thus prefer the one match to the zero? This is my sticking point - I've

Re: Regex Question

2007-01-16 Thread Bill Mill
James Stroud wrote: Bill Mill wrote: Hello all, I've got a test script: start python code = tests2 = [item1: alpha; item2: beta. item3 - gamma--, item1: alpha; item3 - gamma--] def test_re(regex): r = re.compile(regex, re.MULTILINE) for test in tests2:

Re: Regex Question

2007-01-12 Thread James Stroud
Bill Mill wrote: Hello all, I've got a test script: start python code = tests2 = [item1: alpha; item2: beta. item3 - gamma--, item1: alpha; item3 - gamma--] def test_re(regex): r = re.compile(regex, re.MULTILINE) for test in tests2: res = r.search(test)

Re: regex question

2007-01-08 Thread proctor
Paul McGuire wrote: proctor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... hello, i hope this is the correct place... i have an issue with some regex code i wonder if you have any insight: There's nothing actually *wrong* wth your regex. The

Re: regex question

2007-01-08 Thread Steven D'Aprano
On Sun, 07 Jan 2007 23:57:00 -0800, proctor wrote: it does work now...however, one more question: when i type: rx_a = re.compile(r'a|b|c') it works correctly! shouldn't: rx_a = re.compile(makeRE(test)) give the same result since makeRE(test)) returns the string r'a|b|c' Those two

Re: regex question

2007-01-08 Thread proctor
Steven D'Aprano wrote: On Sun, 07 Jan 2007 23:57:00 -0800, proctor wrote: it does work now...however, one more question: when i type: rx_a = re.compile(r'a|b|c') it works correctly! shouldn't: rx_a = re.compile(makeRE(test)) give the same result since makeRE(test)) returns the

Re: regex question

2007-01-08 Thread Mark Peters
is there any way i would be successful then, in using raw string inside my makeRE() function? Why do you think you even need a raw string? Just build and return the string 'a|b|c' (NOTE: DON'T add the quotes to the string) -- http://mail.python.org/mailman/listinfo/python-list

Re: regex question

2007-01-08 Thread Paul McGuire
proctor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] it does work now...however, one more question: when i type: rx_a = re.compile(r'a|b|c') it works correctly! Do you see the difference between: rx_a = re.compile(r'a|b|c') and rx_a = re.compile(r'a|b|c') There is no

Re: regex question

2007-01-08 Thread proctor
Mark Peters wrote: is there any way i would be successful then, in using raw string inside my makeRE() function? Why do you think you even need a raw string? Just build and return the string 'a|b|c' (NOTE: DON'T add the quotes to the string) yes, i suppose you are right. i can't think

Re: regex question

2007-01-08 Thread proctor
Paul McGuire wrote: proctor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] it does work now...however, one more question: when i type: rx_a = re.compile(r'a|b|c') it works correctly! Do you see the difference between: rx_a = re.compile(r'a|b|c') and rx_a =

Re: regex question

2007-01-08 Thread Mark Peters
yes, i suppose you are right. i can't think of a reason i would NEED a raw string in this situation. It looks from your code that you are trying to remove all occurances of one string from the other. a simple regex way would be to use re.sub() import re a = abc b = debcabbde re.sub([ + a

Re: regex question

2007-01-07 Thread Paul McGuire
proctor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... hello, i hope this is the correct place... i have an issue with some regex code i wonder if you have any insight: There's nothing actually *wrong* wth your regex. The problem is your misunderstanding

Re: regex question

2006-08-06 Thread Slawomir Nowaczyk
On Fri, 04 Aug 2006 14:55:34 -0700 John Machin [EMAIL PROTECTED] wrote: # def test(data): # format, index = 'abcd', 0 # for c in data: # i = format.index(c) # if i index+1: # return False # index = i # return index==format.index('d') # #

  1   2   >