Replace some characters in string

Posted on 2011-10-20
Last Modified: 2012-08-14

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.
Question by:Grogel
    LVL 9

    Expert Comment

    This works

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

    Open in new window

    LVL 33

    Expert Comment

    Not unless you nest the Replaces...and that's technically not one pass.
    LVL 83

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now