$$FUNC|$$L|$$R^%TRIM(expr1[,expr2])
echo " string with leading and trailing spaces " | $gtm_dist/mumps -r ^%TRIM
GTM>set strToTrim=$char(9,32)_"string with spaces and tabs"_$char(32,32,32) write $length(strToTrim) 32 GTM>write "strToTrim=",?24,"""",strToTrim,"""",!,"$$L^%TRIM(strToTrim)=",?24,"""",$$L^%TRIM(strToTrim),"""",!,"$$R^%TRIM(strToTrim)=",?24,"""",$$R^%TRIM(strToTrim),"""",!,"$$FUNC^%TRIM(strToTrim)=",?24,"""",$$FUNC^%TRIM(strToTrim),"""" strToTrim= " string with spaces and tabs " $$L^%TRIM(strToTrim)= "string with spaces and tabs " $$R^%TRIM(strToTrim)= " string with spaces and tabs" $$FUNC^%TRIM(strToTrim)="string with spaces and tabs"
$ echo " GT.M Rocks! " | $gtm_dist/mumps -r ^%TRIM GT.M Rocks! $
$$^%MPIECE(str,expr1,expr2)
%MPIECE removes all leading occurrences of expr1 from the result.
GTM>set strToSplit=" please split this string into six" GTM>set piecestring=$$^%MPIECE(strToSplit," ","|") zwrite strToSplit,piecestring write $length(piecestring,"|") strToSplit=" please split this string into six" piecestring="please|split|this|string|into|six 6 GTM>set *fields=$$SPLIT^%MPIECE(strToSplit) zwrite fields fields(1)="please" fields(2)="split" fields(3)="this" fields(4)="string" fields(5)="into" fields(6)="six"