Such as
BPS<4.05|is Missing(BPS) BPS>=2.75 ab>=1961734|is Missing(ab) efg<13741
to
BPS<4.05 BPS>=2.75 ab>=1961734 efg<13741
Thanks!
There isn't a need to use Regexes for this, Words + Word should be enough
Names Default To Here(1); mystr = "\[BPS<4.05|is Missing(BPS) BPS>=2.75 ab>=1961734|is Missing(ab) efg<13741 ]\"; mylist = Words(mystr, "\!N"); comparisons = Transform Each({line}, mylist, Word(1, line, "|"); ); result = Concat Items(comparisons, "\!N");
I prefer to use regular.
mystr = "\[BPS<4.05|is Missing(BPS) BPS>=2.75 ab>=1961734|is Missing(ab) efg<13741 ]\"; t1=Regex(mystr,"\|(.[^)]{0,})\)","",globalreplace);
It can also be a good option. Sometimes regex patterns are difficult to understand and you can end up with difficult patterns (especially if you have corner cases) but it is very flexible
Names Default To Here(1); rgx_parse = function({str}, {Default Local}, // new_str = Regex(str, "\|.+?\)", "", GLOBALREPLACE); new_str = Regex(str, "\|(.[^)]{0,})\)", "", GLOBALREPLACE); return(new_str); ); words_parse = function({str}, {Default Local}, mylist = Words(str, "\!N"); comparisons = Transform Each({line}, mylist, Word(1, line, "|"); ); result = Concat Items(comparisons, "\!N"); ); mystr1 = "\[BPS<4.05|is Missing(BPS) BPS>=2.75 ab>=1961734|is Missing(ab) efg<13741 ]\"; mystr2 = "\[BPS<4.05|is Missing(BPS) BPS>=2.75| ab>=1961734|is Missing(ab) efg<13741 ]\"; mystr3 = "\[BPS<4.05|is Missing(BPS) BPS>=2.75|)abc ab>=1961734|is Missing(ab) efg<13741 ]\"; Show(rgx_parse(mystr1)); Show(words_parse(mystr1)); write("\!N"); Show(rgx_parse(mystr2)); Show(words_parse(mystr2)); write("\!N"); Show(rgx_parse(mystr3)); Show(words_parse(mystr3)); write("\!N");