Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win



Posted on 2004-10-27
Medium Priority
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.
Question by:fpoyavo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 18

Expert Comment

ID: 12431142
you mean something like tihs

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

Accepted Solution

God_Ares earned 2000 total points
ID: 12432439
                 //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
LVL 18

Expert Comment

ID: 12440919
fpoyavo .. What was wrong with my answer?

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

618 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