Re: [pcre-dev] obtaining pattern from a compiled re

Kezdőlap
Üzenet törlése
Szerző: Philip Hazel
Dátum:  
Címzett: Giuseppe Attardi
CC: pcre-dev
Tárgy: Re: [pcre-dev] obtaining pattern from a compiled re
On Thu, 17 Jun 2010, Giuseppe Attardi wrote:

> Is there a way to get back the original string pattern from a compiled pcre?


No. PCRE does not save the original string. It would be possible to
write a function that generates an equivalent string, but it would not
necessarily be the same as the original. For example, "a{0,}" might
become "a*" and "a{0}" might be omitted altogether, "[abcd]" might be
shown as "[a-d]". There are also optimizations: "a+b" would be shown as
"a++b", for example, because PCRE optimizes it that way.

If you run the pcretest program with the -d option, it shows you a form
of the compiled pattern, item by item, but not as a single string.

Why do you want this?

Philip

--
Philip Hazel