Lie Ryan wrote:
MRAB wrote:
You're almost there:
re.subn('\x61','b','')
or better yet:
re.subn(r'\x61','b','')
Wouldn't that becomes a literal \x61 instead of a as it is inside raw
string?
Yes. The re module will understand the \x sequence within a regular
expression
Hello,
why can't I use this pattern
good = re.compile(^[A-ZÄÖÜ].*)
in python3. According to the documentation, patterns may be unicode
strings.
I get this error message:
Traceback (most recent call last):
File ./get.py, line 8, in module
for line in sys.stdin:
File
this is anything to do with the
regular expression? It looks more like it's complaining about
what you've typed in at the console.
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
Simon Strobl wrote:
Hello,
why can't I use this pattern
good = re.compile(^[A-ZÄÖÜ].*)
in python3. According to the documentation, patterns may be unicode
strings.
I get this error message:
Traceback (most recent call last):
File ./get.py, line 8, in module
for line in sys.stdin:
Hello,
why can't I use this statement in python3:
good = re.compile(^[A-ZÄÖÜ].*)
According to the documentation, patterns can be unicode strings.
I get this error message:
Traceback (most recent call last):
File ./get.py, line 8, in module
for line in sys.stdin:
File
Ezio Melotti ezio.melo...@gmail.com added the comment:
Looks like a documentation bug, afaik it has always been
_sre.SRE_Pattern object at 0x00A0BB78 (just checked on Python =2.4).
Maybe it used to be re.RegexObject instance at 80b4150 in older versions.
--
nosy: +ezio.melotti
versions:
Georg Brandl ge...@python.org added the comment:
The output is probably from the stone-aged original re module. Fixed in
r72132.
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5878
Hi,
How can I use the ascii number of a character in a regular expression
(module re) instead of the character itself?
Thanks very much
--
http://mail.python.org/mailman/listinfo/python-list
Thanks very much for your reply.
What I mean is that I would like to use the ascii number in a regular
expression pattern.
For instance, if I want to substitute the occurrences of character 'a' for
the character 'b' in a string, instead of doing this:
re.subn('a','b','')
I'd like to specify
On Tue, Apr 28, 2009 at 4:58 AM, jorma kala jjk...@gmail.com wrote:
Thanks very much for your reply.
What I mean is that I would like to use the ascii number in a regular
expression pattern.
For instance, if I want to substitute the occurrences of character 'a' for
the character 'b
On Tue, Apr 28, 2009 at 4:05 AM, jorma kala jjk...@gmail.com wrote:
Hi,
How can I use the ascii number of a character in a regular expression
(module re) instead of the character itself?
Thanks very much
I refer you to the chr() and ord() built-in functions, which can
certainly be used
jorma kala wrote:
Thanks very much for your reply.
What I mean is that I would like to use the ascii number in a regular
expression pattern.
For instance, if I want to substitute the occurrences of character 'a'
for the character 'b' in a string, instead of doing this:
re.subn('a','b','
John Machin sjmac...@lexicon.net (JM) wrote:
JM On Apr 24, 1:29 am, Piet van Oostrum p...@cs.uu.nl wrote:
obj = re.compile(r'(?:[a-z]+[-0-9]|[0-9]+[-a-z]|-+[0-9a-z])[-0-9a-z]*',
re.I)
JM Understandable and maintainable, I don't think. Suppose that instead
JM the first character is limited
John Machin sjmac...@lexicon.net (JM) wrote:
JM On Apr 23, 8:01 am, krishnaposti...@gmail.com wrote:
Requirements:
The text must contain a combination of numbers, alphabets and hyphen
with at least two of the three elements present.
JM Unfortunately(?), regular expressions can't express
On Apr 24, 1:29 am, Piet van Oostrum p...@cs.uu.nl wrote:
John Machin sjmac...@lexicon.net (JM) wrote:
JM On Apr 23, 8:01 am, krishnaposti...@gmail.com wrote:
Requirements:
The text must contain a combination of numbers, alphabets and hyphen
with at least two of the three elements
My quick attempt is below:
obj = re.compile(r'\b[0-9|a-zA-Z]+[\w-]+')
re.findall(obj, 'TestThis;1234;Test123AB-x')
['TestThis', '1234', 'Test123AB-x']
This is not working.
Requirements:
The text must contain a combination of numbers, alphabets and hyphen
with at least two of the three
On Apr 23, 8:01 am, krishnaposti...@gmail.com wrote:
My quick attempt is below:
obj = re.compile(r'\b[0-9|a-zA-Z]+[\w-]+')
1. Provided the remainder of the pattern is greedy and it will be used
only for findall, the \b seems pointless.
2. What is the | for? Inside a character class, | has no
In article 1bbafe6d-e3bc-4d90-8a0a-0ca82808b...@d14g2000yql.googlegroups.com,
krishnaposti...@gmail.com wrote:
My quick attempt is below:
obj = re.compile(r'\b[0-9|a-zA-Z]+[\w-]+')
re.findall(obj, 'TestThis;1234;Test123AB-x')
['TestThis', '1234', 'Test123AB-x']
This is not working.
What isn't
regular expression, but rather a problem of
the RE engine that is not optimized to use the faster approach when
possible.
This is well known problem very well explained on:
http://swtch.com/~rsc/regexp/regexp1.html
Cheers,
Franck
--
http://mail.python.org/mailman/listinfo/python-list
Jean-Claude Neveu wrote:
Hello,
I was wondering if someone could tell me where I'm going wrong with my
regular expression. I'm trying to write a regexp that identifies whether
a string contains a correctly-formatted currency amount. I want to
support dollars, UK pounds and Euros
On Thu, 09 Apr 2009 02:56:00 -0700, David Liang wrote:
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6 and
3.0):
Basically, any of these:
_re_comments = re.compile(r'^(([^\\]+|\\.|([^\\]+|\\.)*)*)#.*$')
_re_comments = re.compile(r
Steven D'Aprano wrote:
On Thu, 09 Apr 2009 02:56:00 -0700, David Liang wrote:
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6 and
3.0):
Basically, any of these:
_re_comments = re.compile(r'^(([^\\]+|\\.|([^\\]+|\\.)*)*)#.*$')
_re_comments = re.compile(r
On Apr 12, 1:07 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Thu, 09 Apr 2009 02:56:00 -0700, David Liang wrote:
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6 and
3.0):
Basically, any of these:
_re_comments = re.compile(r
IMHO it's not a bug -- s/hang/takes a long time to compute/
That is quite what a hang is, and why the timeout was invented. The
real bug is that there is no timeout mechanism.
Just look at it: 2 + operators and 3 * operators ... It's one of those
come back after lunch REs.
Some users
Dotan Cohen wrote:
IMHO it's not a bug -- s/hang/takes a long time to compute/
That is quite what a hang is, and why the timeout was invented. The
real bug is that there is no timeout mechanism.
I wouldn't call it a hang because it is actually doing work. If it was
'stuck' on a certain
On Apr 11, 10:07 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Thu, 09 Apr 2009 02:56:00 -0700, David Liang wrote:
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6 and
3.0):
Basically, any of these:
_re_comments = re.compile(r
On Sat, 11 Apr 2009 08:40:03 -0700, John Machin wrote:
To my mind, this is a bug in the RE engine. Is there any reason to not
treat it as a bug?
IMHO it's not a bug -- s/hang/takes a long time to compute/
Just look at it: 2 + operators and 3 * operators ... It's one of those
come back
Well, it's been running now for about two and a half hours, that's a
rather long lunch.
I'd also like a pony!
--
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 11, 12:40 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 11 Apr 2009 08:40:03 -0700, John Machin wrote:
To my mind, this is a bug in the RE engine. Is there any reason to not
treat it as a bug?
IMHO it's not a bug -- s/hang/takes a long time to compute/
Steven D'Aprano wrote:
On Sat, 11 Apr 2009 08:40:03 -0700, John Machin wrote:
To my mind, this is a bug in the RE engine. Is there any reason to not
treat it as a bug?
IMHO it's not a bug -- s/hang/takes a long time to compute/
Just look at it: 2 + operators and 3 * operators ... It's one of
On Apr 12, 3:40 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 11 Apr 2009 08:40:03 -0700, John Machin wrote:
To my mind, this is a bug in the RE engine. Is there any reason to not
treat it as a bug?
IMHO it's not a bug -- s/hang/takes a long time to compute/
On Apr 12, 9:46 am, John Machin sjmac...@lexicon.net wrote:
result = _re_comments_nc.sub(r\1, line)
s/_nc// ... that's an artifact of timing it with Non-Capture groups
(?:blahblah) on the two internal groups that don't need to be
capturing (results identical, and no perceptible
On Sat, 11 Apr 2009 16:46:20 -0700, John Machin wrote:
On Apr 12, 3:40 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 11 Apr 2009 08:40:03 -0700, John Machin wrote:
To my mind, this is a bug in the RE engine. Is there any reason to
not treat it as a bug?
IMHO
On Apr 11, 7:31 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
_
My original test has now been running for close to ten hours now, and
still can't be interrupted with ctrl-C. However that's in Python 2.5,
having tried it in Python 2.6.2 they can be interrupted, so I'm
On Apr 12, 10:31 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 11 Apr 2009 16:46:20 -0700, John Machin wrote:
On Apr 12, 3:40 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 11 Apr 2009 08:40:03 -0700, John Machin wrote:
To my mind,
Hello,
I was wondering if someone could tell me where
I'm going wrong with my regular expression. I'm
trying to write a regexp that identifies whether
a string contains a correctly-formatted currency
amount. I want to support dollars, UK pounds and
Euros, but the example below deliberately
On Apr 11, 9:42 pm, Jean-Claude Neveu jcn-france1...@pobox.com
wrote:
My regexp that I'm matching against is: ^\$\£?\d{0,10}(\.\d{2})?$
Here's how I think it should work (but clearly
I'm wrong, because it does not actually work):
^\$\£? Require zero or one instance of $ or £ at the
On Apr 12, 2:19 pm, ru...@yahoo.com wrote:
On Apr 11, 9:42 pm, Jean-Claude Neveu jcn-france1...@pobox.com
wrote:
My regexp that I'm matching against is: ^\$\£?\d{0,10}(\.\d{2})?$
Here's how I think it should work (but clearly
I'm wrong, because it does not actually work):
^\$\£?
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6
and 3.0):
Basically, any of these:
_re_comments = re.compile(r'^(([^\\]+|\\.|([^\\]+|\\.)*)*)#.*$')
_re_comments = re.compile(r'^(([^#]+|\\.|([^\\]+|\\.)*)*)#.*$')
_re_comments = re.compile(r
On Apr 9, 2:56 am, David Liang bmda...@gmail.com wrote:
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6
and 3.0):
Basically, any of these:
_re_comments = re.compile(r'^(([^\\]+|\\.|([^\\]+|\\.)*)*)#.*$')
_re_comments = re.compile(r
On Apr 9, 2:56 am, David Liang bmda...@gmail.com wrote:
Hi all,
I'm having a weird problem with a regular expression (tested in 2.6
and 3.0):
Basically, any of these:
_re_comments = re.compile(r'^(([^\\]+|\\.|([^\\]+|\\.)*)*)#.*$')
_re_comments = re.compile(r
Changes by Amaury Forgeot d'Arc amaur...@gmail.com:
--
resolution: - duplicate
status: open - closed
superseder: - decode_header does not follow RFC 2047
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4958
On Thu, 19 Feb 2009 13:03:59 -0800, Ron Garret wrote:
In article gnkdal$bcq$0...@news.t-online.com,
Peter Otten __pete...@web.de wrote:
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent
components.
How about
More elegant way
[x for x in re.split('([A-Z]+[a-z]+)', a) if x ]
['foo', 'Bar', 'Baz']
R.
On Feb 20, 2:03 pm, Lie Ryan lie.1...@gmail.com wrote:
On Thu, 19 Feb 2009 13:03:59 -0800, Ron Garret wrote:
In article gnkdal$bcq$0...@news.t-online.com,
Peter Otten __pete...@web.de wrote:
('((?=[a-z])(?=[A-Z]))', 'fooBarBaz')
['fooBarBaz']
However, it does seem to work with findall:
re.findall('(?=[a-z])(?=[A-Z])', 'fooBarBaz')
['', '']
So the regular expression seems to be doing the Right Thing. Is this a
bug in re.split, or am I missing something?
(BTW, I tried looking
On Thu, 2009-02-19 at 10:55 -0800, Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]', 'fooBarBaz')
['fo', 'a', 'az']
but it consumes the boundary characters. To fix this I tried using
lookahead and
lookahead and lookbehind patterns instead, but it doesn't work:
re.split('((?=[a-z])(?=[A-Z]))', 'fooBarBaz')
['fooBarBaz']
However, it does seem to work with findall:
re.findall('(?=[a-z])(?=[A-Z])', 'fooBarBaz')
['', '']
So the regular expression seems to be doing the Right Thing
work:
re.split('((?=[a-z])(?=[A-Z]))', 'fooBarBaz')
['fooBarBaz']
However, it does seem to work with findall:
re.findall('(?=[a-z])(?=[A-Z])', 'fooBarBaz')
['', '']
So the regular expression seems to be doing the Right Thing. Is this a
bug in re.split, or am I missing something?
(BTW, I
. To fix this I tried using
lookahead and lookbehind patterns instead, but it doesn't work:
re.split('((?=[a-z])(?=[A-Z]))', 'fooBarBaz')
['fooBarBaz']
However, it does seem to work with findall:
re.findall('(?=[a-z])(?=[A-Z])', 'fooBarBaz')
['', '']
So the regular expression seems
work:
re.split('((?=[a-z])(?=[A-Z]))', 'fooBarBaz')
['fooBarBaz']
However, it does seem to work with findall:
re.findall('(?=[a-z])(?=[A-Z])', 'fooBarBaz')
['', '']
So the regular expression seems to be doing the Right Thing. Is this a
bug in re.split, or am I missing something?
(BTW
')
['', '']
So the regular expression seems to be doing the Right Thing. Is this a
bug in re.split, or am I missing something?
(BTW, I tried looking at the source code for the re module, but I could
not find the relevant code. re.split calls sre_compile.compile().split,
but the string
In article gnkdal$bcq$0...@news.t-online.com,
Peter Otten __pete...@web.de wrote:
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
How about
re.compile([A-Za-z][a-z]*).findall(fooBarBaz)
['foo', 'Bar', 'Baz']
That's very clever. Thanks!
In article mailman.277.1235073073.11746.python-l...@python.org,
andrew cooke and...@acooke.org wrote:
i wonder what fraction of people posting with bug? in their titles here
actually find bugs?
IMHO it ought to be an invariant that len(r.split(s)) should always be
one more than
In article mailman.273.1235071607.11746.python-l...@python.org,
Albert Hopkins mar...@letterboxes.org wrote:
On Thu, 2009-02-19 at 10:55 -0800, Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]',
andrew cooke wrote:
i wonder what fraction of people posting with bug? in their titles here
actually find bugs?
About 99.99%.
Unfortunately, 99.98% have found bugs in their code, not in Python.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Matthew Barnett pyt...@mrabarnett.plus.com added the comment:
This problem has been addressed in issue #2636.
Extra checks have been added to reduce the amount of backtracking.
--
nosy: +mrabarnett
___
Python tracker rep...@bugs.python.org
Tom Lynn tl...@users.sourceforge.net added the comment:
Duplicates issue1047.
--
nosy: +tlynn
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4958
___
Tom Lynn tl...@users.sourceforge.net added the comment:
Oops, duplicates issue 1079 even.
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4958
___
___
I think there are two parts to this question and I am sure lots I am
missing. I am hoping an example will help meI have a html doc that I am
trying to use regular expressions to get a value out of.
here is an example or the line
td colspan='2'Parcel ID: 39-034-15-009 /td
I want to get the number
I think there are two parts to this question and I am sure lots I am
missing. I am hoping an example will help meI have a html doc that I am
trying to use regular expressions to get a value out of.
here is an example or the line
td colspan='2'Parcel ID: 39-034-15-009 /td
I want to get the number
is BeautifulSoup really better? Since I don't know either I would prefer to
learn only one for now.
Thanks
Vincent Davis
On Tue, Jan 27, 2009 at 10:39 AM, MRAB goo...@mrabarnett.plus.com wrote:
Vincent Davis wrote:
I think there are two parts to this question and I am sure lots I am
Vincent Davis wrote:
I think there are two parts to this question and I am sure lots I am
missing. I am hoping an example will help me
I have a html doc that I am trying to use regular expressions to get a
value out of.
here is an example or the line
td colspan='2'Parcel ID: 39-034-15-009 /td
I am trying to parse a set of files that have a simple syntax using
RE. I'm interested in counting '$' expansions in the files, with one
minor consideration. A line becomes a comment if the first non-white
space character is a semicolon.
e.g. tests 1 and 2 should be ignored
sInput =
; $1 test1
martinjamesev...@gmail.com wrote:
I am trying to parse a set of files that have a simple syntax using
RE. I'm interested in counting '$' expansions in the files, with one
minor consideration. A line becomes a comment if the first non-white
space character is a semicolon.
e.g. tests 1 and 2
I am trying to parse a set of files that have a simple syntax using
RE. I'm interested in counting '$' expansions in the files, with one
minor consideration. A line becomes a comment if the first non-white
space character is a semicolon.
e.g. tests 1 and 2 should be ignored
sInput =
; $1
Another option (I cheated a little and turned sInput into a sequence
of lines, similar to what you would get reading a text file):
sInput = [
'; $1 test1',
'; test2 $2',
'test3 ; $3 $3 $3',
'test4',
'$5 test5',
' $6',
' test7 $7 test7',
]
import re
re_exp =
On Mon, 19 Jan 2009 08:08:01 -0800, martinjamesevans wrote:
I am trying to parse a set of files that have a simple syntax using RE.
I'm interested in counting '$' expansions in the files, with one minor
consideration. A line becomes a comment if the first non-white space
character is a
Firstly, a huge thanks to all for the solutions! Just what I was
looking for.
(Aside: why are you doing a case-insensitive match for a non-letter? Are
there different upper- and lower-case dollar signs?)
As you can probably imagine, I had simplified the problem slightly,
the language uses
Gabriel Genellina gagsl-...@yahoo.com.ar added the comment:
Your example header is invalid. Excerpt from RFC2047 http://
www.ietf.org/rfc/rfc2047.txt section 5:
+ An 'encoded-word' MUST NOT be used in parameter of a MIME
Content-Type or Content-Disposition field, or in any structured
Hi:
i'm so newbie in python that i don't get the right idea about regular
expressions. This is what i want to do:
Extract using python some information and them replace this expresion
for others, i use as a base the wikitext and this is what i do:
code file=parse.py
paragraphs =
= Test
scsoce wrote:
MRAB wrote:
div class=moz-text-flowed style=font-family: -moz-fixedSteve
Holden wrote:
Please keep this on the list.
scsoce wrote:
Steve Holden wrote:
scsoce wrote:
say, when I try to search and match every char from variable length
string, such as string '123456', i
On Fri, Nov 21, 2008 at 9:12 PM, scsoce [EMAIL PROTECTED] wrote:
MRAB wrote:
div class=moz-text-flowed style=font-family: -moz-fixedSteve Holden
wrote:
Please keep this on the list.
scsoce wrote:
Steve Holden wrote:
scsoce wrote:
say, when I try to search and match every char from
say, when I try to search and match every char from variable length
string, such as string '123456', i tried re.findall( r'(\d)*, '12346' )
, but only get '6' and Python doc indeed say: If a group is contained
in a part of the pattern that matched multiple times, the last match is
returned.
scsoce wrote:
say, when I try to search and match every char from variable length
string, such as string '123456', i tried re.findall( r'(\d)*, '12346' )
I think you will find you missed a quote out there. Always better to
copy and paste ...
, but only get '6' and Python doc indeed say: If
scsoce [EMAIL PROTECTED] writes:
say, when I try to search and match every char from variable length
string, such as string '123456', i tried re.findall( r'(\d)*, '12346'
) , but only get '6' and Python doc indeed say: If a group is
contained in a part of the pattern that matched multiple
Please keep this on the list.
scsoce wrote:
Steve Holden wrote:
scsoce wrote:
say, when I try to search and match every char from variable length
string, such as string '123456', i tried re.findall( r'(\d)*, '12346' )
I think you will find you missed a quote out there. Always
On 2008-11-21 15:31, scsoce wrote:
say, when I try to search and match every char from variable length
string, such as string '123456',
??? That's a strange requirement. If you want to match every character,
then why are you using a regular expression for this ?
i tried re.findall( r'(\d
Steve Holden wrote:
Please keep this on the list.
scsoce wrote:
Steve Holden wrote:
scsoce wrote:
say, when I try to search and match every char from variable length
string, such as string '123456', i tried re.findall( r'(\d)*, '12346' )
I think you will find you missed a quote out
MRAB wrote:
div class=moz-text-flowed style=font-family: -moz-fixedSteve
Holden wrote:
Please keep this on the list.
scsoce wrote:
Steve Holden wrote:
scsoce wrote:
say, when I try to search and match every char from variable length
string, such as string '123456', i tried re.findall(
my code? Shall I figure out by myself?
Apart from this, in a method I check valid strings with a regular
expression. I pass the string to the method and then Ii have something
like:
m = re.match('[1-9]$', my_string)
I was thinking to put a try except here, so that:
try:
m = re.match('[1-9
: unsupported operand type(s) for +: 'int' and 'str'
Ah, it's a TypeError!
Apart from this, in a method I check valid strings with a regular
expression. I pass the string to the method and then Ii have something
like:
m = re.match('[1-9]$', my_string)
I was thinking to put a try except here, so
Mr.SpOOn:
try:
m = re.match('[1-9]$', my_string)
except:
print 'something...'
...
try:
m.group()
except:
print 'error...'
Generally don't write a nude except, use qualified exceptions, that is
put there one of more exceptions that you want to catch (be careful
with the
In message [EMAIL PROTECTED], Mr.SpOOn
wrote:
On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro
[EMAIL PROTECTED] wrote:
Funny how you never get a thank-you when you tell people to RTFM.
My fault :\
I said thank you to Rob, but I just sent a private message. It's
just that I did a
On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro
[EMAIL PROTECTED] wrote:
In message [EMAIL PROTECTED], Rob
Williscroft wrote:
Read (and bookmark) this:
http://www.python.org/doc/2.5.2/lib/re-syntax.html
Funny how you never get a thank-you when you tell people to RTFM.
My fault :\
I
aaa t bbb a tt š ff 2 '
In this case the regular expression is automatically greedy, matching
the largest area possible. Note however that it won't work if you have
something like this: first second.
Matt
As far as I know, you can't do that with a regular expressions
Lawrence D'Oliveiro wrote in news:[EMAIL PROTECTED] in
comp.lang.python:
In message [EMAIL PROTECTED], Rob
Williscroft wrote:
Read (and bookmark) this:
http://www.python.org/doc/2.5.2/lib/re-syntax.html
Funny how you never get a thank-you when you tell people to RTFM.
Saying Thank
I have a text containing brackets (or what is the correct term for
''?). I'd like to match text in the uppermost level of brackets.
So, I have sth like: ' 123 1 aaa t bbb a tt ff 2
b'. How to match text between the uppermost brackets ( 1 aaa t
bbb a tt ff 2 )?
P.S. sorry
On Oct 31, 1:25 pm, netimen [EMAIL PROTECTED] wrote:
I have a text containing brackets (or what is the correct term for
''?). I'd like to match text in the uppermost level of brackets.
So, I have sth like: ' 123 1 aaa t bbb a tt ff 2
b'. How to match text between the uppermost
On Oct 31, 12:25 pm, netimen [EMAIL PROTECTED] wrote:
I have a text containing brackets (or what is the correct term for
''?). I'd like to match text in the uppermost level of brackets.
So, I have sth like: ' 123 1 aaa t bbb a tt ff 2
b'. How to match text between the
)
' 1 aaa t bbb a tt ff 2 '
In this case the regular expression is automatically greedy, matching
the largest area possible. Note however that it won't work if you have
something like this: first second.
Matt
--
http://mail.python.org/mailman/listinfo/python-list
)
m.group(1)
' 1 aaa t bbb a tt ff 2 '
In this case the regular expression is automatically greedy, matching
the largest area possible. Note however that it won't work if you have
something like this: first second.
Matt
--
http://mail.python.org/mailman/listinfo/python-list
brackets. Anyway it should be
easy to just match the outer most brackets:
import re
text = 123 1 aaa t bbb a tt š ff 2
r = re.compile((.+))
m = r.search(text)
m.group(1)
' 1 aaa t bbb a tt š ff 2 '
In this case the regular expression is automatically greedy
netimen:
Thank's but if i have several top-level groups and want them match one
by one:
text = a b Ó d here starts a new group: e f g
What other requirements do you have? If you list them all at once
people will write you the code faster.
bye,
Bearophile
--
ff 2 '
In this case the regular expression is automatically greedy, matching
the largest area possible. Note however that it won't work if you have
something like this: first second.
Matt
Hi,
Regular expressions or pyparsing might be overkill for this problem ;
you can use
t bbb a tt š ff 2
r = re.compile((.+))
m = r.search(text)
m.group(1)
' 1 aaa t bbb a tt š ff 2 '
In this case the regular expression is automatically greedy, matching
the largest area possible. Note however that it won't work if you have
something like this: first second
In message [EMAIL PROTECTED], Rob
Williscroft wrote:
Read (and bookmark) this:
http://www.python.org/doc/2.5.2/lib/re-syntax.html
Funny how you never get a thank-you when you tell people to RTFM.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Oct 31, 2008 at 8:57 PM, Lawrence D'Oliveiro
[EMAIL PROTECTED] wrote:
In message [EMAIL PROTECTED], Rob
Williscroft wrote:
Read (and bookmark) this:
http://www.python.org/doc/2.5.2/lib/re-syntax.html
Funny how you never get a thank-you when you tell people to RTFM.
--
Carlos Eduardo Klock [EMAIL PROTECTED] added the comment:
Sorry, it is really a problem with the comma.
Thanks for helping! :)
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4219
___
Changes by Georg Brandl [EMAIL PROTECTED]:
--
status: open - closed
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4219
___
___
Python-bugs-list mailing
Hi,
I'd like to use regular expressions to parse a string and accept only
valid strings. What I mean is the possibility to check if the whole
string matches the regex.
So if I have:
p = re.compile('a*b*')
I can match this: 'aabbb'
m = p.match('aabbb')
m.group()
'aabbb'
But I'd
901 - 1000 of 1822 matches
Mail list logo