Click here to Skip to main content
15,503,456 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: a question or thought on manifest file in VC++ Desktop application Pin
dandy7226-Jan-21 8:08
dandy7226-Jan-21 8:08 
GeneralRe: a question or thought on manifest file in VC++ Desktop application Pin
Southmountain26-Jan-21 8:27
Southmountain26-Jan-21 8:27 
GeneralRe: a question or thought on manifest file in VC++ Desktop application Pin
RedDk26-Jan-21 9:07
RedDk26-Jan-21 9:07 
GeneralThought of the Day Pin
OriginalGriff26-Jan-21 5:49
mveOriginalGriff26-Jan-21 5:49 
GeneralRe: Thought of the Day Pin
W Balboos, GHB26-Jan-21 5:55
mveW Balboos, GHB26-Jan-21 5:55 
GeneralRe: Thought of the Day Pin
Dr.Walt Fair, PE26-Jan-21 7:22
professionalDr.Walt Fair, PE26-Jan-21 7:22 
GeneralRe: Thought of the Day Pin
Daniel Pfeffer26-Jan-21 10:31
professionalDaniel Pfeffer26-Jan-21 10:31 
GeneralI'm having a hard time figuring out how to explain what I want Pin
Marc Clifton26-Jan-21 5:01
mvaMarc Clifton26-Jan-21 5:01 
A programming "requirements" problem, not a personal problem.

So, given a string, I want to verify that any instance of "foo" in the string is not a specific instance of "foobar."

For example, give me back the count of only instances of the word "delete" that are not be part of the phrase "deleted = 0"

So this is the best way I can word that requirement generally:

I want a count of the instances of the substring x where the string starting at the index of the substring x does not also start with y, where y is x + some other string z.

Any better ways of wording that?

As for implementation, this is the best I can come up with:

public static class StringExtensionMethods
{
    public static List<int> IndicesOf(this string src, string substring)
    {
        List<int> indices = new List<int>();
        int idx = 0;

        while ((idx = src.IndexOf(substring, idx)) != -1)
        {
            indices.Add(idx);
            ++idx;
        }

        return indices;
    }
}


Example usage:

int count = s.IndicesOf(x).Count(idx => !s.Substring(idx).StartsWith(y));

Just so you don't think this is a programming question. Laugh | :laugh:

GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
W Balboos, GHB26-Jan-21 5:08
mveW Balboos, GHB26-Jan-21 5:08 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Marc Clifton26-Jan-21 9:24
mvaMarc Clifton26-Jan-21 9:24 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
musefan26-Jan-21 5:11
musefan26-Jan-21 5:11 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
PIEBALDconsult26-Jan-21 5:24
professionalPIEBALDconsult26-Jan-21 5:24 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Slacker00726-Jan-21 5:25
professionalSlacker00726-Jan-21 5:25 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
honey the codewitch26-Jan-21 6:00
mvahoney the codewitch26-Jan-21 6:00 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
DerekT-P26-Jan-21 8:08
professionalDerekT-P26-Jan-21 8:08 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Marc Clifton26-Jan-21 9:25
mvaMarc Clifton26-Jan-21 9:25 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Jörgen Andersson26-Jan-21 10:03
professionalJörgen Andersson26-Jan-21 10:03 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
DerekT-P27-Jan-21 0:10
professionalDerekT-P27-Jan-21 0:10 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Jörgen Andersson26-Jan-21 10:26
professionalJörgen Andersson26-Jan-21 10:26 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Nelek26-Jan-21 11:46
protectorNelek26-Jan-21 11:46 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Gerry Schmitz27-Jan-21 7:18
mveGerry Schmitz27-Jan-21 7:18 
GeneralUpdated To A Quote Pin
W Balboos, GHB26-Jan-21 5:00
mveW Balboos, GHB26-Jan-21 5:00 
GeneralIn the distant future . . . Pin
W Balboos, GHB26-Jan-21 2:43
mveW Balboos, GHB26-Jan-21 2:43 
GeneralRe: In the distant future . . . Pin
OriginalGriff26-Jan-21 2:46
mveOriginalGriff26-Jan-21 2:46 
GeneralRe: In the distant future . . . Pin
W Balboos, GHB26-Jan-21 2:49
mveW Balboos, GHB26-Jan-21 2:49 

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.


Straw Poll

How would you describe your current job?
Fighting dragons everyday or clicking the same boxes on the same forms, day after day?
  Results   383 votes