This is a limitation of the underlying pcre implementation, which
leaves out support for collecting repeated matches. Presumably whoever
was working on it decided that no one really needs to do this.
As a workaround, perhaps you could prefix your string with the LF
character, and include the LF character as an option in your pattern?
('FOO|BAR|',LF) rxE LF,'blah blah FOO blah BAR'
1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0
I know this is not precisely identical, but the only other approach I
could see involves pulling down a copy of pcre source code, working
through the architecture to add a mechanism for supporting repeated
matches.
[For example, the code base it pulls from suggests that prefixing your
pattern '(?g)' and then repeatedly calling a match function using the
same compiled pattern and the same string should give successive
matches in that string (and also prefixing it with (?c) should do
fixed width matching, like if you were trying to match dna codons and
did not want misaligned matches -- but both of these features have
been disabled in pcre). That said, if you were interested in doing
this, you'd probably want to work with the current maintainer of
pcre2, which has a changed api, so when you were done there might also
be a little work updating the J DLL calls in the regex implementation
- but that would be the easy part.]
I hope this helps...
--
Raul
On Thu, Mar 31, 2016 at 3:50 AM, Ryan Eckbo <[email protected]> wrote:
> I want to split a string using rxE (which in turn calls rxmatches), but
> it's not behaving as I expect when I use '^'. I want to split on the
> beginning, and two words, e.g:
>
> 'FOO|BAR|^' rxE 'blah blah FOO blah BAR'
> 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0
>
> '^|FOO|BAR' rxE 'blah blah FOO blah BAR'
> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>
> But what I want is
> 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0
>
> I think this has to with rxmatches iteratively beheading the string,
> and '^' matches successive substrings. This was previously a problem
> with rxrplc as well but was recently fixed. Is this also a bug with rxE?
>
> Thanks,
> Ryan
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm