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 line
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 provid
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
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
--
https://mail.python.org/mailman/listi
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
Steven,
Well done!!!
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
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
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)
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
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
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
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
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
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
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
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)
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)
Thanks-
Frank
--
http://mail.python.org/mailman/listinfo/python-list
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.
>
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
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
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
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 group
>>> re.findall('a(b+)', 'ababbaaab')
['
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
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
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
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
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
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 a3 attempt 79')
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
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
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
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
#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
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
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
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
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
=)
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
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.
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)',
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 >
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.
500.675 > 500675
but also
1.000.456.344 > 1
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
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
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
>
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
>
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,
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
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
line = " (0021,xx0A) Siemens: Thorax/Multix FD Lab
"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 charac
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
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
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
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
> 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
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)
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
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
d adds 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 fro
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
[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
>>> 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
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
> 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.
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
-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)
>
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
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):
>
>
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]
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
@param[in] foo
@param[out] bar
Correct? (Note the trailing whitespace in the regex as well as in the
examples)
--
http://mail.python.org/ma
> 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
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.
>>> #
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.
>
> > ##.
[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?
>
>
>
[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
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
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:
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
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?
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
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
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):
> >>>
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
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
>
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
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):
> >>
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
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
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
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('/
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
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
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)
i expect the output to be ['abc'] however it gives m
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
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
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)
> >
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
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)
if res:
p
> 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"
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|
1 - 100 of 135 matches
Mail list logo