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

Página superior
Eliminar este mensaje
Autor: ND
Fecha:  
A: Pcre-dev
Asunto: Re: [pcre-dev] Remove some restrictions of lookbehind assertions
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 last
> position of the subject, and that is probably not what you want.


May be I wrote not exactly accurate regex. May be it need (*SKIP). But it
is enough for understanding a goal. Result would be in capture group 1.


>/(?s).*(?<!\d)\K(?=(\d++))/
>This provides the starting position of the decimal number, with going
> back from the input. This is also much faster than scanning [\G,n-1].


This can't help. I have a STREAM of data. Each subject can have any
length. For example 10 MB. And it consists of many 24kB blocks.


> > 2. There are cases where there is no no programming language available
> for
> > user, only regex. And exactly this case is in one of my application.
>If you have such issues frequently I would recommend to support some
> scripting language. There are many small and fairly quick JS engines,
> which are easy to add. If I remember correctly Duktape or <ˆ


Thanks, Zoltan. In my application I use Lua, I use many-many callouts. But
users are no programmers and no have access to Lua. They use ONLY regexes.
And using script language is very unperformance thing in critical code
sections.

I think we don't discuss how the tasks can be solved by programming
languages, but about what regexes can do. I think EVERY regex task I can
solve by write a number of programming language code. Isn't it?