Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-08 Thread ND via Pcre-dev
On 2019-08-08 16:59, ph10 wrote: On Sat, 3 Aug 2019, ND via Pcre-dev wrote: May be it can be useful to have ability to set a limits of lookbehind search > for performance reasons. > I can imagine a rule: If nonfixedlength lookbehind immediately preceded by > capture group, then it is

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-08 Thread ph10
On Sat, 3 Aug 2019, ND via Pcre-dev wrote: > May be it can be useful to have ability to set a limits of lookbehind search > for performance reasons. > I can imagine a rule: If nonfixedlength lookbehind immediately preceded by > capture group, then it is restricted to start position of this group.

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-03 Thread ND via Pcre-dev
May be it can be useful to have ability to set a limits of lookbehind search for performance reasons. I can imagine a rule: If nonfixedlength lookbehind immediately preceded by capture group, then it is restricted to start position of this group. For example in pattern abc(\w++)(?<=\d+)

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-03 Thread ND via Pcre-dev
On 2019-08-03 04:44, Zoltán Herczeg wrote: I was faced with a need of nonfixed length lookbehind two times: > 1. when data came by stream of 24kB blocks and I need to find a last >numeric in each of it > /.{24000}(?<=(\d++)\D*+)/g Even if this would work, the result of this would be always the

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-02 Thread Zoltán Herczeg
 Hi, > I was faced with a need of nonfixed length lookbehind two times: > 1. when data came by stream of 24kB blocks and I need to find a last >numeric in each of it > /.{24000}(?<=(\d++)\D*+)/g Even if this would work, the result of this would be always the last position of the subject, and

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-02 Thread ND via Pcre-dev
On 2019-08-01 08:20, Zoltán Herczeg wrote: If we would use your idea for doing (0,n-1) match, that could be too slow for large subject, and people would complain. Yes, it could be slow. But: - we can use [\G,n-1] - we can honestly warn about it in docs. Performance of X(?<=Y) will be

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-01 Thread Zoltán Herczeg
> I think MOVE verb like a goto operator in programming languages impacts > the clarity of pattern structure and make it error-prone. It is > undesirable in my opinion. Yes. The idea has already dropped. > I think it will be better to use standard "(?<=)" for lookbehinds, not The problem is

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-08-01 Thread ph10
On Wed, 31 Jul 2019, Zoltán Herczeg wrote: > You have already convinced me to drop MOVE :) > The question is whether we keep the other construct. Or "rematching" a > capturing block in an assertion like fashion would solve this problem better. I don't think that would solve the original

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-31 Thread ND via Pcre-dev
On 2019-07-29 10:45, Zoltán Herczeg wrote: I am open to other names, but I would propose the following control verbs: (*MOVE:mark_name) - This verb changes the current string position to the position recorded by the last mark which name is mark_name. (*SETEND:mark_name) - This verb

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-31 Thread ph10
On Wed, 31 Jul 2019, Zoltán Herczeg wrote: > If we consider the following pattern: > /(*napla:a|a)+/ > > is the same as: > /(?:(*napla:a|a))+/ > > Then we have an empty match if I understand  correctly the behavior of > this new construct. Oh, sorry, I was thinking of

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-31 Thread Zoltán Herczeg
> > You are right. Since you can put it into a group, it is not possible > > to prevent repetitions. However the rule that empty matches break > > (non-fixed) loops may solve this problem. > ... but it's not an empty match. If we consider the following pattern: /(*napla:a|a)+/ is the same as:

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-31 Thread ph10
On Wed, 31 Jul 2019, Zoltán Herczeg wrote: > You are right. Since you can put it into a group, it is not possible > to prevent repetitions. However the rule that empty matches break > (non-fixed) loops may solve this problem. ... but it's not an empty match. > I start to understand why perl

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-31 Thread Zoltán Herczeg
> as normal groups, not as assertion groups. What happens when they are > repeated must be defined - or maybe they should not be allowed to > repeat, because once again that might be an easy way to infinite loops. You are right. Since you can put it into a group, it is not possible to prevent

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-30 Thread ph10
On Tue, 30 Jul 2019, Zoltán Herczeg wrote: > > (*MOVE) is a small addition and solves ND's non-atomic assertion > > requirement. Perhaps we can just start with (*MOVE). > > Yes, if we choose this option to implement. It occurs to me that (*MOVE) gives scope for infinite loops:

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-30 Thread Zoltán Herczeg
> Let me see if I understand that: does (*match:{1}pattern) mean "apply > the pattern to the string that is currently captured by group 1"? > Without looking at the interpreter code, I'm not sure if this is easy or > hard to implement. This is just throwing some ideas. We could also decide that

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-30 Thread ph10
On Tue, 30 Jul 2019, Zoltán Herczeg wrote: > Thinking about practical use cases. With the proposed changes, doing a > submatch is quite overcomplicated: > > (*:A)submatch(*:B)(*MOVE:A)(*SETEND:B)match-submatch-again(*MOVE:B)(*SETEND) > > Perhaps the other idea, use capturing brackets for this

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-30 Thread Zoltán Herczeg
:hzmes...@freemail.hu) > Dátum: 2019 július 29 18:51:34 Tárgy: Re: [pcre-dev] Remove some restrictions of lookbehind assertions Címzett: pcre-dev@exim.org < pcre-dev@exim.org (Link -> mailto:pcre-dev@exim.org) > > > (*SETEND:mark_name) > >   - This verb changes the end pos

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-29 Thread Zoltán Herczeg
> > (*SETEND:mark_name) > >   - This verb changes the end position to the position recorded by the last > > mark which name is > mark_name. If the position is smaller than the current string position, it is > set to the current string > position. > By "end position" do you mean "end of subject"?

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-29 Thread ph10
On Mon, 29 Jul 2019, Zoltán Herczeg wrote: > > May be it not quite effective and still have restrictions but is useful. > > Is it simple to add such functionality? > > Definitely not easy in JIT. Not easy in the interpreter either. > I have an alternative solution which might be able to solve

Re: [pcre-dev] Remove some restrictions of lookbehind assertions

2019-07-29 Thread Zoltán Herczeg
> May be it not quite effective and still have restrictions but is useful. > Is it simple to add such functionality? Definitely not easy in JIT. I have an alternative solution which might be able to solve many of the issues raised here. We already have (*SKIP:name), so we need to record