On Thu, Mar 17, 2022 at 12:45 PM Henry Rich <[email protected]> wrote:
> What does regex do with a situation like this?
Hmm... there's a couple issues here, one has to do with how rplc
(stringreplace) handles ambiguous matches:
(;:'b B1 b B2') stringreplace 'abc'
aB1c
So when we have supplied multiple matches for the same substring, we
use the first match, very much how indices work. The difference is
that substrings have arbitrary lengths.
But this would also mean that
('';'+';'';'-') stringreplace 'ab'
should be equivalent to
('';'+') stringreplace 'ab'
So, dipping into perl (which is the original source for our regex
implementation):
perl -e '$_="ab"; s//+/g; print'
+a+b+
Is that what you were looking for?
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm