Re: Regex Question

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

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 Jussi Piitulainen
Frank Koshti writes: > not always placed in HTML, and even in HTML, they may appear in > strange places, such as Hello. 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 decided to

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)

Re: Regex Question

2012-08-18 Thread Vlastimil Brom
2012/8/18 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 HTM

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

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

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 Roy Smith
In article <385e732e-1c02-4dd0-ab12-b92890bbe...@o3g2000yqp.googlegroups.com>, Frank Koshti 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 proceed. > > > @foo1

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 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. @foo1 @foo2() @f

Re: Regex Question

2012-08-17 Thread Chris Angelico
On Sat, Aug 18, 2012 at 2:41 PM, 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. > > > @foo1 > @foo2() > @foo3(anything could go here)

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

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 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 "", line 1, in IndexErr

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 "", line 1, in > IndexError: no such gr

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

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 Interact

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

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

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

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

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

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.

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 ... 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.sub('(?<=\d)\.(?=\d)',

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 >

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 >

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 >

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

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 origin

Re: RegEx question

2007-10-04 Thread John Masters
On 15:25 Thu 04 Oct , Robert Dailey wrote: > I am not a regex expert, I simply assumed regex was standardized to follow > specific guidelines. There are as many different regex flavours as there are Linux distros. Each follows the basic rules but implements them slightly differently and adds t

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 applica

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

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

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... > > -- > http://mail.python.org

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

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

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

Re: regex question

2007-04-28 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): > >>>

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_te

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 >

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

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

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 pr

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 gi

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

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('/

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_tes

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

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

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

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

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

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'

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'") Th

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

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

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

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 misun

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

Re: regex question

2006-08-04 Thread John Machin
Slawomir Nowaczyk wrote: > On Thu, 03 Aug 2006 22:10:55 +0100 > Gabriel Murray <[EMAIL PROTECTED]> wrote: > > #> Hello, I'm looking for a regular expression > > Some people, when confronted with a problem, think "I know, I'll > use regular expressions." Now they have two problems. >

Re: regex question

2006-08-04 Thread Slawomir Nowaczyk
On Thu, 03 Aug 2006 22:10:55 +0100 Gabriel Murray <[EMAIL PROTECTED]> wrote: #> Hello, I'm looking for a regular expression Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Z

Re: regex question

2006-08-04 Thread John Machin
taleinat wrote: > Gabriel Murray gmail.com> writes: > > > > > Hello, I'm looking for a regular expression which will match strings as > follows: if there are symbols a, b, c and d, then any pattern is valid if it > begins with a and ends with d and proceeds in order through the symbols. > However

Re: regex question

2006-08-04 Thread taleinat
Gabriel Murray gmail.com> writes: > > Hello, I'm looking for a regular expression which will match strings as follows: if there are symbols a, b, c and d, then any pattern is valid if it begins with a and ends with d and proceeds in order through the symbols. However, at any point the pattern ma

Re: regex question

2006-08-03 Thread Alex Ross
This might be more flexible: pat = re.compile(r"^(a*(?=b)b*(?=[ac])c*(?=[abd])d*)+$") tests = [('aabbbaabbcccbbbcccddd', True), ('aabcabcd', True), ('abcd', True), ('aabbccaabbccabcabababbb', True), ('aabbccaabbccabcabababbbabcd', True),

Re: regex question

2006-08-03 Thread Tim Chase
> That's great! Thanks for the quick response. Yeah, abcdcd should be > possible too. The below passes that test now as well as a couple others I tossed at it. I changed it from a one-line regexp to a VERBOSE regexp to make it easier to read and see what's going on. You may be able to see th

Re: regex question

2006-08-03 Thread Tim Chase
Gabriel Murray wrote: > Hello, I'm looking for a regular expression which will match strings as > follows: if there are symbols a, b, c and d, then any pattern is valid if it > begins with a and ends with d and proceeds in order through the symbols. > However, at any point the pattern may reset to

Re: regex question

2005-06-25 Thread Paul McGuire
Here's a pyparsing version of this, that may be easier to maintain long term (although if you have your heart set on learning regexp's, they will certainly do the job). Note that in pyparsing, you don't have to spell out where the whitespace goes - pyparsing's default logic assumes that whitespace

Re: regex question

2005-06-25 Thread George Sakkis
"Felix Schwarz" <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm experiencing problems with a regular expression and I can't figure > out which words I use when googling. I read the python documentation for > the re module multiple times now but still no idea what I'm doing wrong. > > What I want to d

Re: regex question

2005-06-25 Thread Helmut Jarausch
Felix Schwarz wrote: > Hi all, > > I'm experiencing problems with a regular expression and I can't figure > out which words I use when googling. I read the python documentation for > the re module multiple times now but still no idea what I'm doing wrong. > > What I want to do: > - Extract all