Ok, looking at the error it gives, it seems that there's a problem
with the current implementation of rxmerge where it doesn't deal with
some match arguments.
You can work around that problem for this example like this:
(,new) (,/(pat;,1+i.4) rxmatches test) rxmerge test
a
( 3,4
5,6 )
c
( 11,12
13,14 )
This makes the x argument to rxmerge be rank 1 and reduces the m
argument to rxmerge to rank 2 (which is what its current
implementation assumes you gave it).
I hope this helps,
--
Raul
On Thu, Apr 11, 2019 at 1:46 PM Raul Miller <[email protected]> wrote:
>
> And... I see I misread your post... hang on and ignore my previous
> message, I've got some other things I'm focusing on (or supposed to be
> focussing on), but this looks like something that should be easy to
> answer....
>
> sorry about the noise...
>
> --
> Raul
>
> On Thu, Apr 11, 2019 at 1:39 PM Raul Miller <[email protected]> wrote:
> >
> > I get a different result from what you got, which suggests you had
> > changed your regexp, perhaps to something like this:
> >
> > pat =: '\(\s+(\d+)\,(\d+)\s+(\d+)\,(\d+)\s+\)'
> >
> > Ah... I now see that your followup has an updated pattern...
> >
> > ---------------
> >
> > Anyways, what I don't understand is what you meant by:
> >
> > "How can I merge this result back to the variable test."
> >
> > Do you mean that you want to replace matched digit sequences in that
> > text with some sort of representation of their offsets?
> >
> > Or are you intending something else?
> >
> > Thanks,
> >
> > --
> > Raul
> >
> > On Thu, Apr 11, 2019 at 1:01 PM Nimp O <[email protected]> wrote:
> > >
> > > Hello everyone,
> > > Here is a minimal working example of what I'm trying to accomplish:
> > >
> > > load'regex'
> > > pat =: '\( (\d)\,(\d)\s+(\d)\,(\d)\s+\)'
> > >
> > > test=: 0 : 0
> > >
> > > a
> > >
> > > ( 2,3
> > >
> > > 4,5 )
> > >
> > > c
> > >
> > > ( 10,11
> > >
> > > 12,13 )
> > >
> > > )
> > >
> > >
> > > So using the regex pattern I was able to extract the numbers from this
> > > string. Each subgroup correspond to a single number.
> > >
> > >
> > > ]mat=: ((pat;,1+i.4) rxmatches test) rxfrom test
> > > +--+--+--+--+
> > > |2 |3 |4 |5 |
> > > +--+--+--+--+
> > > |10|11|12|13|
> > > +--+--+--+--+
> > >
> > > Suppose I changed this matrix such as in:
> > >
> > > ]new =: >:&.".&.> mat
> > >
> > > +--+--+--+--+
> > >
> > > |3 |4 |5 |6 |
> > >
> > > +--+--+--+--+
> > >
> > > |11|12|13|14|
> > >
> > > +--+--+--+--+
> > >
> > >
> > > How can I merge this result back to the variable test.
> > >
> > >
> > > I tried applying the function directly using rxapply but it only replaced
> > > the first match.
> > >
> > >
> > > (pat;,1+i.4) >:&.". rxapply test
> > > a
> > >
> > > ( 3,3
> > >
> > > 4,5 )
> > >
> > > c
> > >
> > > ( 11,11
> > >
> > > 12,13 )
> > >
> > > And also tried using rxmerge but got the following error:
> > >
> > > new ( (pat;,1+i.4) rxmatches test) rxmerge test
> > >
> > > |length error: rxcut_jregex_
> > >
> > > | 'beg len' =.|:,.x
> > >
> > > Does anyone know how to extend these functions for dealing with multiple
> > > subgroups of matching terms? For me the merge case is more important
> > > since it allows different transformations on each group.
> > > Thanks.
> > >
> > >
> > >
> > >
> > >
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm