No I want to have enhanced {}-tags which remove the text dependendly what content is on the left and right side of the braces.
{123_} should keep '123' when there is regular text directly after the closing brace (so it should do the same as '{123}')
{_123} should keep '123' if there is regular text before the opening brace
{_123} should keep '123' only if there is regular text before AND after the braces
Any ideas how to do a fast working code?
Code: Select all
Procedure.s OldTagRemove(text.s)
Protected n,na,nb
na=1
Repeat
na=FindString(text,"{",na)
nb=FindString(text,"}",na)
If na And nb
If nb<Len(text);
If Mid(text,nb+1,1)<>"{"
text=Left(text,na-1)+Mid(text,na+1,nb-na-1)+Mid(text,nb+1)
Else
text=Left(text,na-1)+Mid(text,nb+1);
EndIf
Else
text=Left(text,na-1)+Mid(text,nb+1);
EndIf
Else
n=#True
EndIf
Until n
ProcedureReturn text
EndProcedure
Procedure.s NewTagRemove(text.s)
ProcedureReturn "n/a"
EndProcedure
Debug OldTagRemove("{1}{2}{3} *A* {1} *B* {2}{3}")
Debug NewTagRemove("{_1}{_2}{_3} *A* {_1} *B* {_2}{_3}"); should be ' *A* 1 *B* 2'
Debug NewTagRemove("{1_}{2_}{3_} *A* {1_} *B* {2_}{3_}"); should be '3 *A* 1 *B*'
Debug NewTagRemove("{_1_}{_2_}{_3_} *A* {_1_} *B* {_2_}{_3_}"); should be ' *A* 1 *B* '