Solved

REPLACE 5

Posted on 2004-10-27
149 Views
Last Modified: 2010-04-15
Hi Experts,

I need to replace all occurances of hyphen and space BETWEEN CHARACTERS (not digits) ONLY within text string with nothing.
example:    ABC- EFH     becomes ABCEFH

Thank you.
0
Question by:fpoyavo
    3 Comments
     
    LVL 18

    Expert Comment

    by:armoghan
    you mean something like tihs

    string str = "ABC- EFH- XYZ";
    Console.WriteLine(str.Replace(" ","").Replace ("-",""));
    0
     
    LVL 7

    Accepted Solution

    by:
                     //using System.Text.RegularExpressions;

                      Regex r= new Regex(@"-\s*");
                      MessageBox.Show( r.Replace("abd- asd") );

    when you need

    abc      -     def

    to be adcdef  replace Regex r= new Regex(@"-\s*"); with Regex r= new Regex(@"\s*-\s*");


    now it will do : abc      def


    just giving you options
    0
     
    LVL 18

    Expert Comment

    by:armoghan
    fpoyavo .. What was wrong with my answer?
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Product Review - Android Remix

    Come along for the ride with our Senior Product Manager, Brian Matis, as he reviews the Android Remix.

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

    857 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

    13 Experts available now in Live!

    Get 1:1 Help Now