Click here to Skip to main content
15,888,733 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 7:08
dandy7226-Jan-21 7:08 
GeneralRe: a question or thought on manifest file in VC++ Desktop application Pin
Southmountain26-Jan-21 7:27
Southmountain26-Jan-21 7:27 
GeneralRe: a question or thought on manifest file in VC++ Desktop application Pin
RedDk26-Jan-21 8:07
RedDk26-Jan-21 8:07 
GeneralThought of the Day Pin
OriginalGriff26-Jan-21 4:49
mveOriginalGriff26-Jan-21 4:49 
GeneralRe: Thought of the Day Pin
W Balboos, GHB26-Jan-21 4:55
W Balboos, GHB26-Jan-21 4:55 
GeneralRe: Thought of the Day Pin
Dr.Walt Fair, PE26-Jan-21 6:22
professionalDr.Walt Fair, PE26-Jan-21 6:22 
GeneralRe: Thought of the Day Pin
Daniel Pfeffer26-Jan-21 9:31
professionalDaniel Pfeffer26-Jan-21 9:31 
GeneralI'm having a hard time figuring out how to explain what I want Pin
Marc Clifton26-Jan-21 4:01
mvaMarc Clifton26-Jan-21 4: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 4:08
W Balboos, GHB26-Jan-21 4:08 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Marc Clifton26-Jan-21 8:24
mvaMarc Clifton26-Jan-21 8:24 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
musefan26-Jan-21 4:11
musefan26-Jan-21 4:11 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
PIEBALDconsult26-Jan-21 4:24
mvePIEBALDconsult26-Jan-21 4:24 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Slacker00726-Jan-21 4:25
professionalSlacker00726-Jan-21 4:25 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
honey the codewitch26-Jan-21 5:00
mvahoney the codewitch26-Jan-21 5:00 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
DerekT-P26-Jan-21 7:08
professionalDerekT-P26-Jan-21 7:08 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Marc Clifton26-Jan-21 8:25
mvaMarc Clifton26-Jan-21 8:25 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Jörgen Andersson26-Jan-21 9:03
professionalJörgen Andersson26-Jan-21 9:03 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
DerekT-P26-Jan-21 23:10
professionalDerekT-P26-Jan-21 23:10 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Jörgen Andersson26-Jan-21 9:26
professionalJörgen Andersson26-Jan-21 9:26 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Nelek26-Jan-21 10:46
protectorNelek26-Jan-21 10:46 
GeneralRe: I'm having a hard time figuring out how to explain what I want Pin
Gerry Schmitz27-Jan-21 6:18
mveGerry Schmitz27-Jan-21 6:18 
GeneralUpdated To A Quote Pin
W Balboos, GHB26-Jan-21 4:00
W Balboos, GHB26-Jan-21 4:00 
GeneralIn the distant future . . . PinPopular
W Balboos, GHB26-Jan-21 1:43
W Balboos, GHB26-Jan-21 1:43 
GeneralRe: In the distant future . . . Pin
OriginalGriff26-Jan-21 1:46
mveOriginalGriff26-Jan-21 1:46 
GeneralRe: In the distant future . . . Pin
W Balboos, GHB26-Jan-21 1:49
W Balboos, GHB26-Jan-21 1: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.