Link to home
Start Free TrialLog in
Avatar of Member_2_4286571
Member_2_4286571

asked on

Replace some characters in string

Hi.

I have working POS application which prints receipt directly to POS printer using ESCAPE codes to format receipt.
Now, some printers doesn't support my local language code and instead some letters i am receving garbage on print.

For Example: "This is sa&es Da*t$"...

The question is, how can i search whole string and replace certain characters (&,*,$) with (l,e,s).

I know of String.Replace but is there way to do this in one pass of the string?

Thank you.
Avatar of sachinpatil10d
sachinpatil10d
Flag of India image

This works

"This is sa&es Da*t$".Replace("&","l").Replace("*","e").Replace("$","s")

Open in new window

Avatar of Paul MacDonald
Not unless you nest the Replaces...and that's technically not one pass.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial