[issue405358] Python2.0 re module: greedy regexp bug

2022-04-10 Thread admin
Change by admin : -- github: None -> 34046 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue429357] non-greedy regexp duplicating match bug

2022-04-10 Thread admin
Change by admin : -- github: None -> 34572 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue408936] Python2.0 re module: greedy regexp bug 2

2022-04-10 Thread admin
Change by admin : -- github: None -> 34154 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue231635] ConfigParser module regexp issue

2022-04-10 Thread admin
Change by admin : -- github: None -> 33890 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46410] TypeError when parsing regexp with unicode named character sequence escape

2022-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: >>> import unicodedata >>> unicodedata.lookup('KEYCAP NUMBER SIGN') '#️' >>> print(ascii(unicodedata.lookup('KEYCAP NUMBER SIGN'))) '#\ufe0f\u20e3' Support of Unicode Named Character Sequences in the unicodeescape codec and in the RE parser would be a new

[issue46410] TypeError when parsing regexp with unicode named character sequence escape

2022-01-18 Thread Matthew Barnett
Matthew Barnett added the comment: They're not supported in string literals either: Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> "\N{KEYCAP NUMBER SIGN}" File "",

[issue46410] TypeError when parsing regexp with unicode named character sequence escape

2022-01-17 Thread Jirka Marsik
cently added support for Unicode Named Character Sequences (https://www.unicode.org/Public/13.0.0/ucd/NamedSequences.txt). Trying to use these named character sequences in a regular expression leads to a 'TypeError', as the regexp parser tries to call 'ord' on a string with length > 1. ---

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2020-10-19 Thread Gregory P. Smith
Gregory P. Smith added the comment: 2.7 is end of life. if you have regular expression performance issues with something in 3, please open a new issue. -- nosy: +gregory.p.smith resolution: -> wont fix stage: -> resolved status: pending -> closed

[issue40043] RegExp Conditional Construct (?(id/name)yes-pattern|no-pattern) Problem

2020-03-26 Thread Matthew Barnett
Matthew Barnett added the comment: That's what searching does! Does the pattern match here? If not, advance by one character and try again. Repeat until a match is found or you've reached the end. -- ___ Python tracker

[issue40043] RegExp Conditional Construct (?(id/name)yes-pattern|no-pattern) Problem

2020-03-25 Thread Leon Hampton
Leon Hampton added the comment: Matthew Barnett & SilentGhost, Thank you for your prompt responses. (Really prompt. Amazing!) SilentGhost, Regarding your response, I used re.search, not re.match. When I used re.match, the regex failed. When I used re.search, it matched. Here are my tests.

[issue40043] RegExp Conditional Construct (?(id/name)yes-pattern|no-pattern) Problem

2020-03-22 Thread SilentGhost
SilentGhost added the comment: Leon, this most likely is not a bug, not because what's stated in documentation, but because you're most likely not testing what you think you do. Here is the test that you should be doing: >>> re.match(r'(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)', '>> No match. If

[issue40043] RegExp Conditional Construct (?(id/name)yes-pattern|no-pattern) Problem

2020-03-22 Thread Matthew Barnett
Matthew Barnett added the comment: The documentation is talking about whether it'll match at the current position in the string. It's not a bug. -- resolution: -> not a bug ___ Python tracker

[issue40043] RegExp Conditional Construct (?(id/name)yes-pattern|no-pattern) Problem

2020-03-22 Thread Leon Hampton
the Conditional Construct, it gives this sample pattern '(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)' and states that the pattern WILL NOT MATCH this string ' RegExp Conditional Construct (?(id/name)yes-pattern|no-pattern) Problem ___ Python tracker

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2019-09-09 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37687] Invalid regexp should rise exception

2019-07-25 Thread Matthew Barnett
Matthew Barnett added the comment: For historical reasons, if it isn't valid as a repeat then it's a literal. This is true in other regex implementations, and is by no means unique to the re module. -- resolution: -> not a bug stage: -> resolved status: open -> closed

[issue37687] Invalid regexp should rise exception

2019-07-25 Thread belegnar
atus: open title: Invalid regexp should rise exception versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue37687> ___ ___ Python-bugs-list mailing list Uns

[issue35543] re.sub is only replacing max. of 2 string found by regexp.

2018-12-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The third argument of re.sub() is the maximal number of replacements. re.I == 2. sub(pattern, repl, string, count=0, flags=0) Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the

[issue35543] re.sub is only replacing max. of 2 string found by regexp.

2018-12-20 Thread Sagar
PC" "BUILTIN"', 2) >>> dat = '"10GE" "4x" "AMPC" "SFP+" "ether" "xe" "DOWN" "MPC" "BUILTIN"' >>> type = >>> re.subn(r'\"BUILTIN\"|\"B\d\"|

Re: Reg python regexp

2018-03-21 Thread Youta TAKAOKA
` option. `lgrep -f` uses pattern as just a fixed text, not regexp. 2018年3月21日(水) 20:35 Rhodri James <rho...@kynesim.co.uk>: > On 21/03/18 10:44, sankarram...@gmail.com wrote: > > Hi, > > > > I have a requirement. > > > > cmd="cat |grep -c 'if [ -t 1 ];

Re: Reg python regexp

2018-03-21 Thread Rhodri James
On 21/03/18 10:44, sankarram...@gmail.com wrote: Hi, I have a requirement. cmd="cat |grep -c 'if [ -t 1 ]; then mesg n 2>/dev/null; fi'" I need to escape only the square brackets in above variable since its not grepping without escaping the brackets. You need to escape the square brackets

Re: Reg python regexp

2018-03-21 Thread Chris Angelico
On Wed, Mar 21, 2018 at 9:44 PM, wrote: > Hi, > > I have a requirement. > > cmd="cat |grep -c 'if [ -t 1 ]; then mesg n 2>/dev/null; fi'" > > I need to escape only the square brackets in above variable since its not > grepping without escaping the brackets. > > Please

Re: Reg python regexp

2018-03-21 Thread Paul Moore
Hi, You don't need a regexp for this, the "replace" method on a string will do what you want: >>> s = 'this is a [string' >>> print(s.replace('[', '\\[')) this is a \[string Paul On 21 March 2018 at 10:44, <sankarram...@gmail.com> wrote: > Hi, > >

Reg python regexp

2018-03-21 Thread sankarramanv
Hi, I have a requirement. cmd="cat |grep -c 'if [ -t 1 ]; then mesg n 2>/dev/null; fi'" I need to escape only the square brackets in above variable since its not grepping without escaping the brackets. Please help. Thanks. -- https://mail.python.org/mailman/listinfo/python-list

Re: RegExp - please help me!

2017-12-27 Thread szykcech
> (?s)struct (.+?)\s*\{\s*(.+?)\s*\}; Thank you Vlastimil Brom for regexp and for explanation! -- https://mail.python.org/mailman/listinfo/python-list

Re: RegExp - please help me!

2017-12-27 Thread Lele Gaifax
szykc...@gmail.com writes: > Please help me with this regexp or tell me that I neeed do this in other way. I think that using regexps to parse those structures is fragile and difficult to get right[0], as there are lots of corner cases (comments, complex types, ...). I'd suggest using a t

Re: RegExp - please help me! (Posting On Python-List Prohibited)

2017-12-26 Thread szykcech
W dniu wtorek, 26 grudnia 2017 21:53:14 UTC+1 użytkownik Lawrence D’Oliveiro napisał: > On Wednesday, December 27, 2017 at 2:15:21 AM UTC+13, szyk...@gmail.com wrote: > > struct (.+)\s*{\s*(.+)\s*}; > > You realize that “.” matches anything? Whereas I think you want to match > non-whitespace in

Re: RegExp - please help me!

2017-12-26 Thread Peter Pearson
On Tue, 26 Dec 2017 05:14:55 -0800 (PST), szykc...@gmail.com wrote: [snip] > So: I develop regexp which to my mind should work, but it doesn't and > I don't know why. The broken regexp is like this: > struct (.+)\s*{\s*(.+)\s*}; [snip] You'll probably get better help faster if you ca

Re: RegExp - please help me!

2017-12-26 Thread Vlastimil Brom
nctions can > appear bellow my struct definition and makes inappropriate further regexp > filtering (against variables). > > So: I develop regexp which to my mind should work, but it doesn't and I > don't know why. The broken regexp is like this: > struct (.+)\s*{\s*(.+)\s*}; >

RegExp - please help me!

2017-12-26 Thread szykcech
truct name and 2) struct definition. Struct definition I need because some inline functions can appear bellow my struct definition and makes inappropriate further regexp filtering (against variables). So: I develop regexp which to my mind should work, but it doesn't and I don't know why. The bro

How to use a regexp here

2017-12-08 Thread Cecil Westerhof
I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to implement this? -- Cecil Westerhof Senior

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Rick Johnson writes: >> There is now also a line that starts with: PCH_CPU_TEMP: >> And I do not want that one. > > Yes. But be aware, that while the `str.startswith(target)` > method is indeed more efficient than a more generalized > "inclusion test", if the target

Re: How to use a regexp here

2017-12-08 Thread breamoreboy
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line.

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Neil Cerutti writes: > On 2017-12-04, Cecil Westerhof wrote: >> Joel Goldstick writes: >> >>> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >>> wrote: >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote:

Re: How to use a regexp here

2017-12-08 Thread Neil Cerutti
On 2017-12-04, Cecil Westerhof wrote: > Joel Goldstick writes: > >> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >> wrote: >> >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >>> I have a script that was running perfectly

Re: How to use a regexp here

2017-12-08 Thread Terry Reedy
On 12/4/2017 11:14 AM, Ned Batchelder wrote: > On 12/4/17 9:13 AM, Rick Johnson wrote: >> Perhaps it's not politically correct for me to say this, but >> i've never been one who cared much about political >> correctness, so i'm just going to say it... > > Cecil, feel free to ignore the rest of

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: > Perhaps it's not politically correct for me to say this, but > i've never been one who cared much about political > correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.â His messages are famous for their

Re: How to use a regexp here

2017-12-08 Thread Joel Goldstick
On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder wrote: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: > >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed,

Re: How to use a regexp here

2017-12-08 Thread Rick Johnson
ask of a ~~Senior~~ Software Engineer that they possess the basic skills required to peruse the Python documentation and decide which method is most appropriate for the situation at hand. And if you're using Python on a regular basis, then you should be intimately familiar with _all_ methods of ea

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Joel Goldstick writes: > On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder > wrote: > >> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> >>> I have a script that was running perfectly for some time. It uses: >>> array = [elem for elem in output

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line. What would be the best way

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Ned Batchelder writes: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed, I have to check for CPU_TEMP at

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Neil Cerutti writes: > On 2017-12-04, Cecil Westerhof wrote: >> Joel Goldstick writes: >> >>> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >>> wrote: >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote:

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Rick Johnson writes: >> There is now also a line that starts with: PCH_CPU_TEMP: >> And I do not want that one. > > Yes. But be aware, that while the `str.startswith(target)` > method is indeed more efficient than a more generalized > "inclusion test", if the target

Re: How to use a regexp here

2017-12-04 Thread Neil Cerutti
On 2017-12-04, Cecil Westerhof wrote: > Joel Goldstick writes: > >> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >> wrote: >> >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >>> I have a script that was running perfectly

Re: How to use a regexp here

2017-12-04 Thread Terry Reedy
On 12/4/2017 11:14 AM, Ned Batchelder wrote: On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.  His messages are famous for their

Re: How to use a regexp here

2017-12-04 Thread Rick Johnson
too much to ask of a ~~Senior~~ Software Engineer that they possess the basic skills required to peruse the Python documentation and decide which method is most appropriate for the situation at hand. And if you're using Python on a regular basis, then you should be intimately familiar with _all_ methods

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Joel Goldstick writes: > On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder > wrote: > >> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> >>> I have a script that was running perfectly for some time. It uses: >>> array = [elem for elem in output

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Ned Batchelder writes: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed, I have to check for CPU_TEMP at

Re: How to use a regexp here

2017-12-04 Thread Joel Goldstick
On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder wrote: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: > >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed,

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to

Re: How to use a regexp here

2017-12-04 Thread breamoreboy
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line.

How to use a regexp here

2017-12-04 Thread Cecil Westerhof
I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to implement this? -- Cecil Westerhof Senior

Re: Validating regexp

2017-08-10 Thread Larry Martell
ve seen still require some input length (I'm thinking >>>>> exponential rematch backoff stuff here). I suspect that if your test >>>>> query matches the RE against a fixed empty string it is hard to be >>>>> exploited. i.e. I think most of this st

Re: Validating regexp

2017-08-10 Thread alister via Python-list
past, >>>>> and I wouldn't want to rely on there not being any now. >>>> >>>> >>>> The ones I've seen still require some input length (I'm thinking >>>> exponential rematch backoff stuff here). I suspect that if your test >>

Re: Validating regexp

2017-08-10 Thread Larry Martell
gt;> >>> The ones I've seen still require some input length (I'm thinking >>> exponential >>> rematch backoff stuff here). I suspect that if your test query matches >>> the RE >>> against a fixed empty string it is hard to be exploited. i.e. I think &g

Re: Validating regexp

2017-08-10 Thread Jon Ribbens
(I'm thinking >>> exponential rematch backoff stuff here). I suspect that if your >>> test query matches the RE against a fixed empty string it is hard >>> to be exploited. i.e. I think most of this stuff isn't expensive >>> in terms of compiling the regexp but i

Re: Validating regexp

2017-08-09 Thread Cameron Simpson
ited. i.e. I think most of this stuff isn't expensive in terms of compiling the regexp but in executing it against text. Well yes, but presumably if the OP is receiving regexps from users they will be executed against text sooner or later. True, but the OP (Larry) was after validation. The

Re: Validating regexp

2017-08-09 Thread Larry Martell
rry Martell <larry.mart...@gmail.com> >>> wrote: >>>> Anyone have any code or know of any packages for validating a regexp? >>>> >>>> I have an app that allows users to enter regexps for db searching. >>>> When a user enters an invalid one

Re: Validating regexp

2017-08-09 Thread TheSeeker
On Tuesday, August 8, 2017 at 11:38:34 AM UTC-5, larry@gmail.com wrote: > Anyone have any code or know of any packages for validating a regexp? > > I have an app that allows users to enter regexps for db searching. > When a user enters an invalid one (e.g. 'A|B|' is on

Re: Validating regexp

2017-08-09 Thread Jon Ribbens
ail.com> >>> wrote: >>>> Yeah, it does not throw for 'A|B|' - but mysql chokes on it with empty >>>> subexpression for regexp' I'd like to flag it before it gets to SQL. >>> >>> Okay, so your definition of validity is "what MySQL will accept"

Re: Validating regexp

2017-08-09 Thread Peter Heitzer
Larry Martell <larry.mart...@gmail.com> wrote: >On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico <ros...@gmail.com> wrote: >> On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell <larry.mart...@gmail.com> >> wrote: >>> Anyone have any code or know of any packag

Re: Validating regexp

2017-08-08 Thread Cameron Simpson
mpty subexpression for regexp' I'd like to flag it before it gets to SQL. Okay, so your definition of validity is "what MySQL will accept". In that case, I'd feed it to MySQL and see if it accepts it. Regexps are sufficiently varied that you really need to use the same engine for validation as f

Re: Validating regexp

2017-08-08 Thread Jon Ribbens
On 2017-08-08, Chris Angelico <ros...@gmail.com> wrote: > On Wed, Aug 9, 2017 at 2:57 AM, Larry Martell <larry.mart...@gmail.com> wrote: >> Yeah, it does not throw for 'A|B|' - but mysql chokes on it with empty >> subexpression for regexp' I'd like to flag it before i

Re: Validating regexp

2017-08-08 Thread Chris Angelico
yone have any code or know of any packages for validating a regexp? >>> >>> I have an app that allows users to enter regexps for db searching. >>> When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it >>> causes downstream issues. I'd like to flag it at

Re: Validating regexp

2017-08-08 Thread Larry Martell
yone have any code or know of any packages for validating a regexp? >>> >>> I have an app that allows users to enter regexps for db searching. >>> When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it >>> causes downstream issues. I'd like to flag it at

Re: Validating regexp

2017-08-08 Thread Chris Angelico
On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell <larry.mart...@gmail.com> wrote: > Anyone have any code or know of any packages for validating a regexp? > > I have an app that allows users to enter regexps for db searching. > When a user enters an invalid one (e.g. 'A|B|'

Re: Validating regexp

2017-08-08 Thread Larry Martell
On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico <ros...@gmail.com> wrote: > On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell <larry.mart...@gmail.com> wrote: >> Anyone have any code or know of any packages for validating a regexp? >> >> I have an app that all

Re: Validating regexp

2017-08-08 Thread Skip Montanaro
> I have an app that allows users to enter regexps for db searching. > When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it > causes downstream issues. I'd like to flag it at entry time. Just call re.compile(...) on it and catch any exceptions, modulo caveats about operating with

Re: Validating regexp

2017-08-08 Thread MRAB
On 2017-08-08 17:37, Larry Martell wrote: Anyone have any code or know of any packages for validating a regexp? I have an app that allows users to enter regexps for db searching. When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it causes downstream issues. I'd like to flag

Validating regexp

2017-08-08 Thread Larry Martell
Anyone have any code or know of any packages for validating a regexp? I have an app that allows users to enter regexps for db searching. When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it causes downstream issues. I'd like to flag it at entry time. -- https://mail.python.org

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Lele Gaifax
Serhiy Storchaka writes: > Seems the documentation is not accurate. Could you file a report on > https://bugs.python.org/ ? Thank you everybody answered! Here it is: http://bugs.python.org/issue28450 ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Peter Otten
Serhiy Storchaka wrote: > On 14.10.16 20:01, Peter Otten wrote: > def double_bs(s): return "".join(s.split("\\")) >> ... > Just use s.replace('\\', r'\\'). D'oh! -- https://mail.python.org/mailman/listinfo/python-list

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Serhiy Storchaka
On 14.10.16 19:15, Chris Angelico wrote: I wasn't specifically aware that the re module was doing the same thing, but it'll be from the same purpose and goal. The idea is that, for instance, Windows path names in non-raw string literals will no longer behave differently based on whether the path

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Serhiy Storchaka
On 14.10.16 20:01, Peter Otten wrote: Lele Gaifax wrote: So, how am I supposed to achieve the mentioned intent? By doubling the escape in the replacement? If there are no escape sequences aimed to be handled by re.sub() you can escape the replacement wholesale: re.sub(r'\s+',

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Serhiy Storchaka
On 14.10.16 18:40, Lele Gaifax wrote: Hi all, trying out pgcli with Python 3.6.0b2 I got an error related to what seem a different behaviour, or even a bug, of re.sub(). The original intent is to replace spaces within a string with the regular expression \s+ (see

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 4:48 AM, Ned Batchelder wrote: > On Friday, October 14, 2016 at 1:27:09 PM UTC-4, Chris Angelico wrote: >> On Sat, Oct 15, 2016 at 4:12 AM, Ned Batchelder >> wrote: >> > There doesn't seem to be a change to string literals

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Ned Batchelder
On Friday, October 14, 2016 at 1:27:09 PM UTC-4, Chris Angelico wrote: > On Sat, Oct 15, 2016 at 4:12 AM, Ned Batchelder > wrote: > > There doesn't seem to be a change to string literals at all. It's only a > > change in the regex engine. > > > > Python 3.6.0b2

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Ned Batchelder writes: > On Friday, October 14, 2016 at 12:50:44 PM UTC-4, Lele Gaifax wrote: >> Chris Angelico writes: >> >> > There's a shift as of 3.6 to make unrecognized alphabetic escapes into >> > errors, or at least warnings. >> >> But we are

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 4:12 AM, Ned Batchelder wrote: > There doesn't seem to be a change to string literals at all. It's only a > change in the regex engine. > > Python 3.6.0b2 (default, Oct 10 2016, 21:30:05) > [GCC 4.2.1 Compatible Apple LLVM 7.0.2

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Ned Batchelder
On Friday, October 14, 2016 at 1:00:12 PM UTC-4, Chris Angelico wrote: > On Sat, Oct 15, 2016 at 3:45 AM, Lele Gaifax wrote: > > Chris Angelico writes: > > > >> There's a shift as of 3.6 to make unrecognized alphabetic escapes into > >> errors, or at least

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Ned Batchelder
On Friday, October 14, 2016 at 12:50:44 PM UTC-4, Lele Gaifax wrote: > Chris Angelico writes: > > > There's a shift as of 3.6 to make unrecognized alphabetic escapes into > > errors, or at least warnings. > > But we are talking about raw strings here, specifically r'\s+'. > >

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Peter Otten
Lele Gaifax wrote: > Peter Otten <__pete...@web.de> writes: > >> Lele Gaifax wrote: >> >>> The original intent is to replace spaces within a string with the >>> regular expression \s+ (see >>> ... >>> Accordingly to the documentation >>> (https://docs.python.org/3.6/library/re.html#re.sub)

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 3:45 AM, Lele Gaifax wrote: > Chris Angelico writes: > >> There's a shift as of 3.6 to make unrecognized alphabetic escapes into >> errors, or at least warnings. > > But we are talking about raw strings here, specifically r'\s+'. >

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Lele Gaifax writes: > And the documentation as well, to clarify the fact immediately, without > assuming one will scroll down to the "changed in version" part (at least, that > is what seem the rule in other parts of the manual). Also, I'd prefer the "Changed in 3.6" be

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Chris Angelico writes: > There's a shift as of 3.6 to make unrecognized alphabetic escapes into > errors, or at least warnings. But we are talking about raw strings here, specifically r'\s+'. I agree that with plain strings it's a plus. ciao, lele. -- nickname: Lele Gaifax

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Peter Otten <__pete...@web.de> writes: > Lele Gaifax wrote: > >> The original intent is to replace spaces within a string with the regular >> expression \s+ (see >> ... >> Accordingly to the documentation >> (https://docs.python.org/3.6/library/re.html#re.sub) “unknown escapes [in >> the repl

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Peter Otten
Lele Gaifax wrote: > Hi all, > > trying out pgcli with Python 3.6.0b2 I got an error related to what seem a > different behaviour, or even a bug, of re.sub(). > > The original intent is to replace spaces within a string with the regular > expression \s+ (see >

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 2:40 AM, Lele Gaifax wrote: > Accordingly to the documentation > (https://docs.python.org/3.6/library/re.html#re.sub) > “unknown escapes [in the repl argument] such as \& are left alone”. > > Am I missing something, or is this a regression? Further

Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Hi all, trying out pgcli with Python 3.6.0b2 I got an error related to what seem a different behaviour, or even a bug, of re.sub(). The original intent is to replace spaces within a string with the regular expression \s+ (see

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-09-02 Thread Steve Newcomb
Steve Newcomb added the comment: On 08/30/2016 12:46 PM, Raymond Hettinger wrote: > Raymond Hettinger added the comment: > > It would be helpful if you ... make a small set of regular expressions that > demonstrate the performance regression. > Done. Attachments: test.py : Code that exercises

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-09-01 Thread Steve Newcomb
Steve Newcomb added the comment: On 09/01/2016 05:01 PM, Steve Newcomb wrote: > >> The outputs show that 2.7.12's re.sub() takes 1.2 times as long as >> 2.7.6's. It's a significant difference, but... >> >> ...it was not the dramatic degradation I expected to find in this >> exercise. On

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-09-01 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo type: -> performance ___ Python tracker ___

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-09-01 Thread Steve Newcomb
Steve Newcomb added the comment: Oops. The correct url is sftp://coolheads.com/files/py-re-perform-276v2712/ On 09/01/2016 04:52 PM, Steve Newcomb wrote: > On 08/30/2016 12:46 PM, Raymond Hettinger wrote: >> Raymond Hettinger added the comment: >> >> It would be helpful if you ... make a small

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-08-30 Thread Steve Newcomb
Steve Newcomb added the comment: On 08/30/2016 01:24 PM, Serhiy Storchaka wrote: > Serhiy Storchaka added the comment: > > According to your profile results all re functions are 2.5-4 times faster > under 2.7.12 than under 2.7.6. May be I misinterpret it? I can't explain the profiler's report.

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-08-30 Thread Steve Newcomb
Steve Newcomb added the comment: On 08/30/2016 12:46 PM, Raymond Hettinger wrote: > Raymond Hettinger added the comment: > > It would be helpful if you could run "hg bisect" with your set-up to isolate > the change that causes the problem. I don't think I understand you. There's no difference

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-08-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: According to your profile results all re functions are 2.5-4 times faster under 2.7.12 than under 2.7.6. May be I misinterpret it? Note that 96-99% of time (2847.099 of 2980.718 seconds under 2.7.6 and 4474.890 of 4519.872 seconds under 2.7.12) is spent in

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-08-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: It would be helpful if you could run "hg bisect" with your set-up to isolate the change that causes the problem. Alternatively, make a small set of regular expressions that demonstrate the performance regression. -- nosy: +rhettinger

[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-08-30 Thread Steve Newcomb
any further information I can. Any insights about this surprisingly severe performance degradation would be welcome. -- files: profiles_2.7.6_vs_2.7.12 messages: 273932 nosy: steve.newcomb priority: normal severity: normal status: open title: regexp performance degradation between 2.7.6

RegExp help

2016-02-10 Thread Larry Martell
Given this string: >>> s = """|Type=Foo ... |Side=Left""" >>> print s |Type=Foo |Side=Left I can match with this: >>> m = re.search(r'^\|Type=(.*)$\n^\|Side=(.*)$',s,re.MULTILINE) >>> print m.group(0) |Type=Foo |Side=Left >>> print m.group(1) Foo >>> print m.group(2) Left But when I try and

  1   2   3   4   5   6   7   8   9   10   >