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

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 a

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 help. You're putting this

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, wrote: > Hi, > &g

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 usin

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 f

Re: RegExp - please help me!

2017-12-26 Thread Vlastimil Brom
r 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*}; > As you can see it

RegExp - please help me!

2017-12-26 Thread szykcech
t 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.

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 Softwar

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 is not _always_ at the > begin

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

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: > I have a script that was running perfectly for some time. It uses: > a

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 for some time. It uses: array = [elem for elem in output if

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 Rick

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 outra

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, I have to check for CPU_

Re: How to use a regexp here

2017-12-08 Thread Rick Johnson
cts, i don't think it's 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 shou

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 if 'CPU_TEMP' in elem] >>> >>> But because output h

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 the >> beginning of the l

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: > I have a script that was running perfectly for some time. It uses: > a

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 is not _always_ at the > begin

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 for some time. It uses: array = [elem for elem in output if

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 message

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 outrageo

Re: How to use a regexp here

2017-12-04 Thread Rick Johnson
on in your projects, i don't think it's 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, th

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 if 'CPU_TEMP' in elem] >>> >>> But because output h

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 the >> beginning of the l

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, I have to check for CPU_

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 impl

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 Softwa

Re: Validating regexp

2017-08-10 Thread Larry Martell
ast, >>>>>> 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

Re: Validating regexp

2017-08-10 Thread alister via Python-list
;>> >>>> 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.

Re: Validating regexp

2017-08-10 Thread Larry Martell
; 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 rege

Re: Validating regexp

2017-08-10 Thread Jon Ribbens
;> 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 in executing it against text. >> >>Well yes, but presumably if the OP is receiv

Re: Validating regexp

2017-08-09 Thread Cameron Simpson
y 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 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 comp

Re: Validating regexp

2017-08-09 Thread Larry Martell
On Wed, Aug 9, 2017 at 6:13 AM, Peter Heitzer wrote: > Larry Martell wrote: >>On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico wrote: >>> On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell >>> wrote: >>>> Anyone have any code or know of any packages for valid

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

Re: Validating regexp

2017-08-09 Thread Jon Ribbens
On 2017-08-09, Cameron Simpson wrote: > On 08Aug2017 17:31, Jon Ribbens wrote: >>On 2017-08-08, Chris Angelico wrote: >>> On Wed, Aug 9, 2017 at 2:57 AM, Larry Martell >>> wrote: >>>> Yeah, it does not throw for 'A|B|' - but mysql chokes on

Re: Validating regexp

2017-08-09 Thread Peter Heitzer
Larry Martell wrote: >On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico wrote: >> On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell >> wrote: >>> Anyone have any code or know of any packages for validating a regexp? >>> >>> I have an app that allows users t

Re: Validating regexp

2017-08-08 Thread Cameron Simpson
On 08Aug2017 17:31, Jon Ribbens wrote: On 2017-08-08, Chris Angelico wrote: On Wed, Aug 9, 2017 at 2:57 AM, Larry Martell 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

Re: Validating regexp

2017-08-08 Thread Jon Ribbens
On 2017-08-08, Chris Angelico wrote: > On Wed, Aug 9, 2017 at 2:57 AM, Larry Martell 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 y

Re: Validating regexp

2017-08-08 Thread Chris Angelico
On Wed, Aug 9, 2017 at 2:57 AM, Larry Martell wrote: > On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico wrote: >> On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell >> wrote: >>> Anyone have any code or know of any packages for validating a regexp? >>> >>>

Re: Validating regexp

2017-08-08 Thread Larry Martell
On Tue, Aug 8, 2017 at 12:57 PM, Larry Martell wrote: > On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico wrote: >> On Wed, Aug 9, 2017 at 2:37 AM, Larry Martell >> wrote: >>> Anyone have any code or know of any packages for validating a regexp? >>> >>>

Re: Validating regexp

2017-08-08 Thread Chris Angelico
On Wed, Aug 9, 2017 at 2:37 AM, 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 >

Re: Validating regexp

2017-08-08 Thread Larry Martell
On Tue, Aug 8, 2017 at 12:51 PM, Chris Angelico wrote: > On Wed, Aug 9, 2017 at 2:37 AM, 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

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 u

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

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

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 pensato ieri real: Emanu

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.escape(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 https://github.com/dbcli/pgcl

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 at all. It's only a >> > change in the regex engi

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 (default, Oct 10 2016, 21:30:05

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 talking about raw strings here, specificall

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 (clang-700.1.81)] on darwin > Typ

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 warnings. > > > > But we are talking abo

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+'. > > I agree that with

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

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+'. > > I agree that with plain strings it's a

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 less ambiguous whether it

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 | Quando vivrò di q

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 argu

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 > https://github.com/dbcli/pgcli/blo

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 down, you'll find this

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 https://github.com/dbcli/pgcli/blob/master/pgcli/packages/prioritizat

Re: RegExp help

2016-02-10 Thread MRAB
On 2016-02-11 03:09, Larry Martell wrote: On Wed, Feb 10, 2016 at 10:00 PM, MRAB wrote: On 2016-02-11 02:48, Larry Martell wrote: 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=(.*)$',

Re: RegExp help

2016-02-10 Thread Larry Martell
On Wed, Feb 10, 2016 at 10:00 PM, MRAB wrote: > On 2016-02-11 02:48, Larry Martell wrote: >> >> 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=(.*)$'

Re: RegExp help

2016-02-10 Thread MRAB
On 2016-02-11 02:48, Larry Martell wrote: 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)

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 sub

Re: Why is regexp not working?

2014-07-05 Thread Denis McMahon
On Fri, 04 Jul 2014 14:27:12 +0200, Florian Lindner wrote: > self.regexps = [r"it (?P\d+) .* dt complete yes | > write-iteration-checkpoint |", > r"it (?P\d+) read ahead" My first thought is what is the effect of '|' as the last character in the regex? -- Denis McMahon, denismf

Re: Why is regexp not working?

2014-07-04 Thread MRAB
") for regexp in cre: match = regexp.match(block) for grp in regexp.groupindex: data = match.group(grp) if match else None self.data[grp].append(data) block is a list of strings, terminated by \n. self.regexps: self.r

Why is regexp not working?

2014-07-04 Thread Florian Lindner
Hello, I have that piece of code: def _split_block(self, block): cre = [re.compile(r, flags = re.MULTILINE) for r in self.regexps] block = "".join(block) print(block) print("---") for regexp in cre:

Re: small regexp help

2013-10-30 Thread jianbing . tai
On Thursday, October 31, 2013 12:56:49 AM UTC+8, rusi wrote: > Well it seems that we are considerably closer to a solution to the GG > double-spaced crap problem. > > > > Just wondering if someone can suggest a cleanup of the regexp part > > > > Currently I

small regexp help

2013-10-30 Thread rusi
Well it seems that we are considerably closer to a solution to the GG double-spaced crap problem. Just wondering if someone can suggest a cleanup of the regexp part Currently I have (elisp) (defun clean-gg () (interactive) 1 (replace-regexp "^> *\n> *\n> *$" "-=\

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Joel Goldstick
ture the single preceding character. E.g. in sed: >>> >>>sed -e 's/\(.\)$hello\$/\1XXX/' >>> >>> but some RE engines (Perl's, for example) allow you specify zero-width >>> assertions. You could, in Perl, write >>> >

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Ed Morton
without having to capture whatever preceded the target string. But since Perl also has negative zero-width look-behind you can code your request even more directly: s/(? I dont wanna be tied to a specific language etc so I just want a regexp and as many versions as possible. Maybe I should try

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Ben Bacarisse
Rivka Miller writes: > Thanks everyone, esp this gentleman. Kind of you to single me out, but it was Janis Papanagnou who first posted the solution that you say "works best" for you. -- Ben. -- http://mail.python.org/mailman/listinfo/python-list

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Asen Bozhilov
Rivka Miller wrote: > I am looking for a regexp for a string not at the beginning of the > line. > > For example, I want to find $hello$ that does not occur at the > beginning of the string, ie all $hello$ that exclude ^$hello$. The begging of the string is zero width character. S

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Janis Papanagnou
Am 26.10.2012 06:45, schrieb Rivka Miller: Thanks everyone, esp this gentleman. Who is "this"? The solution that worked best for me is just to use a DOT before the string as the one at the beginning of the line did not have any char before it. Which was what I suggested, and where you rude

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Devin Jeanpierre
On Thu, Oct 25, 2012 at 10:00 PM, Ed Morton wrote: > Because there is no solution - there IS no _RE_ that will match a string not > at the beginning of a line. Depending on what the OP meant, the following would both work: - r"^(?!mystring)" (the string does not occur at the beginning) - r"(?!^)

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Rivka Miller
some RE engines (Perl's, for example) allow you specify zero-width > assertions.  You could, in Perl, write > >   s/(?<=.)\$hello\$/XXX/ > > without having to capture whatever preceded the target string.  But > since Perl also has negative zero-width look-behind you can code your &g

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread anon
On Thu, 25 Oct 2012 18:08:53 -0700 (PDT), Rivka Miller wrote in <73f60cf3-d932-4366-a405-676748856...@q16g2000yqc.googlegroups.com>: >no one has really helped yet. We regret that you are not a satisfied customer. Please take your receipt to the cashier and you will receive double your money bac

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread David Hutto
> I want to search and modify. > > I dont wanna be tied to a specific language etc so I just want a > regexp and as many versions as possible. If you just find the one command line app that will perform the task, like awk, then the other languages you will just need to call the commandline

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Mark Lawrence
On 25/10/2012 21:53, Rivka Miller wrote: Hello Programmers, I am looking for a regexp for a string not at the beginning of the line. Why bother with a silly regex thingy when simple string methods will suffice e.g. 'yourstring'.find('xyz', 1) or 'yourstring&#

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Ben Bacarisse
pture whatever preceded the target string. But since Perl also has negative zero-width look-behind you can code your request even more directly: s/(? I dont wanna be tied to a specific language etc so I just want a > regexp and as many versions as possible. Maybe I should try in emacs > and so

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread MRAB
to a specific language etc so I just want a regexp and as many versions as possible. Maybe I should try in emacs and so I am now posting to emacs groups also, although javascript has rich set of regexp facilities. examples $hello$ should not be selected but not hello but all of the $hello$ and $

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Ed Morton
f producing the same output, but that's not the question you're asking. Ed. I want to search and modify. I dont wanna be tied to a specific language etc so I just want a regexp and as many versions as possible. Maybe I should try in emacs and so I am now posting to emacs groups also

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Dave Angel
On 10/25/2012 09:08 PM, Rivka Miller wrote: > On Oct 25, 2:27 pm, Danny wrote: >> Why you just don't give us the string/input, say a line or two, and what you >> want off of it, so we can tell better what to suggest > no one has really helped yet. > > > > first non beginning of the line and I wi

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Rivka Miller
just want a regexp and as many versions as possible. Maybe I should try in emacs and so I am now posting to emacs groups also, although javascript has rich set of regexp facilities. examples $hello$ should not be selected but not hello but all of the $hello$ and $hello$ ... $hello$ each o

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Zero Piraeus
: On 25 October 2012 16:53, Rivka Miller wrote: > I am looking for a regexp for a string not at the beginning of the > line. There are probably quite a few ways to do this, but '(?>> pattern = re.compile(r"(?>> re.findall(pattern, "this is some text") [

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Janis Papanagnou
On 25.10.2012 22:53, Rivka Miller wrote: > Hello Programmers, > > I am looking for a regexp for a string not at the beginning of the > line. > > For example, I want to find $hello$ that does not occur at the > beginning of the string, ie all $hello$ that exclude ^$hello$

Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Rivka Miller
Hello Programmers, I am looking for a regexp for a string not at the beginning of the line. For example, I want to find $hello$ that does not occur at the beginning of the string, ie all $hello$ that exclude ^$hello$. In addition, if you have a more difficult problem along the same lines, I

Re: equiv of perl regexp grammar?

2012-09-13 Thread Ian Kelly
On Thu, Sep 13, 2012 at 5:30 AM, Neal Becker wrote: > I noticed this and thought it looked interesting: > > http://search.cpan.org/~dconway/Regexp- > Grammars-1.021/lib/Regexp/Grammars.pm#DESCRIPTION > > I'm wondering if python has something equivalent? The pyparsing modu

  1   2   3   4   5   6   >