Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
function TForm1.ReplaceMyStr(const Match: TMatch): String;
Result := '';
if Match.Success then
s := Copy(Match.Value, 2, Match.Length-2); //exclude brackets
if Length(s) > 0 then
if TryStrToInt(s, i) then
Result := Chr(i);
procedure TForm1.Button1Click(Sender: TObject);
iCC := 0;
input := '<2>Test<3><13><10>';
myEval := ReplaceMyStr;
Label2.Caption := regex.Replace(input, '<[^>]+>', myEval);
Open in new window
s := '<2>Test<3><13><10>';
s := StringReplace(s, '<2>', Chr(2), [rfReplaceall]);
s := StringReplace(s, '<3>', Chr(3), [rfReplaceall]);
s := StringReplace(s, '<10>', Chr(10), [rfReplaceall]);
s := StringReplace(s, '<13>', Chr(13), [rfReplaceall]);
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Members can enroll in this course at no extra cost.