Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
AnswerRe: performance counter in visual studio 217 C# Pin
Eddy Vluggen20-Sep-17 23:20
professionalEddy Vluggen20-Sep-17 23:20 
QuestionC#-Form-DataGridView-Hangs Pin
Member 1341980320-Sep-17 3:05
Member 1341980320-Sep-17 3:05 
AnswerRe: C#-Form-DataGridView-Hangs Pin
Richard MacCutchan20-Sep-17 3:27
mveRichard MacCutchan20-Sep-17 3:27 
AnswerRe: C#-Form-DataGridView-Hangs Pin
Eddy Vluggen20-Sep-17 3:38
professionalEddy Vluggen20-Sep-17 3:38 
Questionmatching exact word c# Pin
Love Allah19-Sep-17 12:42
Love Allah19-Sep-17 12:42 
AnswerRe: matching exact word c# Pin
PIEBALDconsult19-Sep-17 12:45
mvePIEBALDconsult19-Sep-17 12:45 
GeneralRe: matching exact word c# Pin
Love Allah19-Sep-17 13:00
Love Allah19-Sep-17 13:00 
AnswerRe: matching exact word c# Pin
OriginalGriff19-Sep-17 20:02
mveOriginalGriff19-Sep-17 20:02 
I think you are getting a bit confused here, you appear to be using two different method to do the same thing, but both of them half-heartedly. You never check if the match worked for example!
The simplest way to do this is to throw away the Regex - since you aren't actually using it at all - and just use the Split:
string words = "hello helloworld worldhello";
string[] lis = word.Split(' ');
List<string> outp = new List<string>();
foreach (string word in lis)
    {
    if (word != "hello")
        {
        outp.Add(word);
        }
    }
words = string.Join(" ", outp);
Console.WriteLine(words);
If you want to use a Regex, then it's not too bad:
string words = "hello helloworld worldhello";
words = Regex.Replace(words, @"\b" + "hello"  + "\b", "");
Console.WriteLine(words);

Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

QuestionHow to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 4:55
Bootzilla3319-Sep-17 4:55 
SuggestionRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming19-Sep-17 5:22
mveRichard Deeming19-Sep-17 5:22 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 5:32
Bootzilla3319-Sep-17 5:32 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming19-Sep-17 5:57
mveRichard Deeming19-Sep-17 5:57 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 6:05
Bootzilla3319-Sep-17 6:05 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 9:58
Bootzilla3319-Sep-17 9:58 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
eddieangel19-Sep-17 12:18
eddieangel19-Sep-17 12:18 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3320-Sep-17 2:56
Bootzilla3320-Sep-17 2:56 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming20-Sep-17 10:01
mveRichard Deeming20-Sep-17 10:01 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 3:58
Bootzilla3321-Sep-17 3:58 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming21-Sep-17 4:32
mveRichard Deeming21-Sep-17 4:32 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 4:52
Bootzilla3321-Sep-17 4:52 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming21-Sep-17 5:18
mveRichard Deeming21-Sep-17 5:18 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 5:41
Bootzilla3321-Sep-17 5:41 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming21-Sep-17 6:07
mveRichard Deeming21-Sep-17 6:07 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 6:15
Bootzilla3321-Sep-17 6:15 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming21-Sep-17 6:19
mveRichard Deeming21-Sep-17 6:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.