I am aware of these possibilities, but they are not very helpful in
what I want to achieve.
Consider Perl's "s///gr" operator, e.g. "s/-(\d+)-+(\d+)-/$2-$1/gr".
I try to emulate it in J like this:
subst_xchg =: 3 : 0
rh =. rxcomp '-(\d+)-+(\d+)-'
xchg =. [: (] , '-' , [)&>/ ] rxfrom~ (rh;1 2) rxmatch ]
rh xchg rxapply y
)
This is a simplification again. In my real use case, the verb that
acts as the operand to rxapply is again assembled from other local
verbs. Inserting everything into the rxapply sentence would make it
completely unreadable.
Which leads to option 2: fix the verb. Sadly, this seems not to be
possible. I don't know why, but in my installation I get:
rh =. rxcomp '-(\d+)-+(\d+)-'
xchg =. [: (] , '-' , [)&>/ ] rxfrom~ (rh;1 2) rxmatch ]
xchg '-12--34-'
34-12
xchg f. '-12--34-'
|value error: regcomp
| regcomp p
This brings me to the question about "f:". Maybe it could help here.
For me the best solution would be fixing "rxapply" to use "u." instead of "u".
The only working alternative is to declare the participating verbs as
global. I just dislike that.
Best regards,
-jo
On Fri 21 Aug 2026 05:10:00 PM CEST, Jose Mario Quintana