With just NAV it will be a lot of C/AL coding, but you can look at the DotNet string object and use all the C# string conversion tools, maybe that will help.
As per the example provided by you , You can try the below mentioned code.
OutputText:='';
i:=0;
REPEAT
i:=i+1;
IF EVALUATE(Char1,COPYSTR(InputText,i,1)) THEN;
j := Char1;
IF ((j>=48) AND (j<=57)) THEN BEGIN
IF EVALUATE(j,FORMAT(Char1)) THEN;
REPEAT
IF EVALUATE(Char2,COPYSTR(InputText,i+1,1))THEN;
OutputText:=OutputText+FORMAT(Char2);
j:=j-1;
UNTIL j=1;
END ELSE
OutputText:=OutputText+FORMAT(Char1);
UNTIL (i=STRLEN(InputText));
i,j are integers
Char1,Char2 are Characters
InputText and Output Text are Text variables
IF COPYSTR(stOrig,i,1) = COPYSTR(stOld,1,1) THEN
BEGIN
IF COPYSTR(stOrig,i,len2) = stOld THEN
BEGIN
st := st + stNew;
i := i + len2-1;
END
ELSE
st := st + COPYSTR(stOrig,i,1);
END
ELSE
st := st + COPYSTR(stOrig,i,1);
i := i + 1;
UNTIL i = len+1;
Name DataType Subtype Length
dotNetString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
navStr1 Text
navStr2 Text
Name DataType Subtype Length
dotNetString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
navStr1 Text
navStr2 Text
Comments
As per the example provided by you , You can try the below mentioned code.
i,j are integers
Char1,Char2 are Characters
InputText and Output Text are Text variables
Rishi
although i tried the below code: but didn't worked:
Procedure Replace (stOrig : Text[250];stOld : Text[250];stNew : Text[250]) : Text[250]
IF stNew = stOld THEN
EXIT(stOrig);
i := 1;
len := STRLEN(stOrig);
len2 := STRLEN(stOld);
REPEAT
IF COPYSTR(stOrig,i,1) = COPYSTR(stOld,1,1) THEN
BEGIN
IF COPYSTR(stOrig,i,len2) = stOld THEN
BEGIN
st := st + stNew;
i := i + len2-1;
END
ELSE
st := st + COPYSTR(stOrig,i,1);
END
ELSE
st := st + COPYSTR(stOrig,i,1);
i := i + 1;
UNTIL i = len+1;
EXIT(st);
Rishi
dotNetString := dotNetString.Replace(navStr1,navStr2);
Variables:
Name DataType Subtype Length
dotNetString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
navStr1 Text
navStr2 Text
NAV Developer