Re: [pcre-dev] ability to name a regexp and reuse it in anot…

Página Principal
Apagar esta mensagem
Autor: Zoltán Herczeg
Data:  
Para: Philippe Strauss
CC: pcre-dev
Assunto: Re: [pcre-dev] ability to name a regexp and reuse it in another one
Hi,

you can use named recursion for that. Search for (DEFINE) in http://perldoc.perl.org/perlre.html However, you should remember that recursion is atomic in PCRE.

Or if you use a script language you can simply assign a string variable and concatenate it:

word = "[\p{Latin}\-]+"
regex="(" + word + "," + word + ")+"

Just be creative ;)

Regards,
Zoltan

Philippe Strauss <philippe@???> írta:
>Hello PCRE developpers,>
>

I find myself the last few days writing pcre regexp like :>
>

"^([\\p{Latin}\\-]+)\\s(?i:v|var)(?::|\\.|\\s)\\s?([\\p{Latin}\\-]+)\\s(?i:f|forme)(?::|\\.|\\s)\\s?([\\p{Latin}\\-]+)$">
>

the double backslash beeing a thing of the String module of the host language, ocaml here.>
>

Is there any plan to add a feature enabling the user to name a part of a regexp like :>
>

[\p{Latin}\-]+>
>

(which is just a souped up \w+)>
>

and reuse it later, would allow more readable writing of long regexp.>
(in that particular case, the naming could be \w, redifining \w)>
>

would be a really nice feature !>
>

Note that I'm subscribing to this list just to ask about this, sorry if it's an FAQ.>
>

-->
Philippe Strauss>
http://www.strauss-acoustics.ch/>
>

-- >
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev >