NB. Perl-compatible regular expression library
NB. with POSIX interface
NB.
NB. See Licence and pcre-man.pdf for details, as well as
NB. http://www.perldoc.com/perl5.8.0/pod/perlre.html
NB.
NB. INSTALL
NB.    copy to <j>/addons/pcre
NB.
NB. USE
NB.    load'~addons/pcre/regex.ijs'
NB.
NB.    The rest is just like J regex
NB.
NB. RATIONALE
NB.    - fast and efficient becoming practical on large input
NB.    - richer syntax and posibilities
NB.    - simpler API structs
NB.    - compatible with Perl and .NET
NB.    - BSD licence, i.e. free for commercial use and binary distribution
NB.    - TBD: total regex unlimited (not 50)
NB.    - TBD: subexpressions can be dynamically allocated (not 50)
NB.
NB. BINARIES
NB.    http://gnuwin32.sourceforge.net/packages/pcre.htm
NB.
NB. REVISIONS
NB.    12/05/04 Oleg Kobchenko Initial release (pcre-5.0)

require 'regex'
cocurrent 'jregex'

rxdll=: jpath'~addons\pcre\pcre.dll '
rxcdm=: 1 : '(rxdll,x.)&(15!:0)'

NB. =========================================================
NB. J DLL calls corresponding to the four extended regular expression
NB. functions defined in The Single Unix Specification, Version 2
jregcomp=: 'regcomp + i *x *c i' rxcdm
jregexec=: 'regexec + i *x *c x *i i' rxcdm
jregerror=: 'regerror + x i * *c x' rxcdm
jregfree=: 'regfree + n *x' rxcdm

NB. =========================================================
rxnsub=: [: >: 1&{   NB. Number of main+sub-expressions from Perl regex_t