How to find the index of the first char in a string that is not in a list

I know I can loop over the string or build a regex or invert the set (ASCII isn't that big after all) and search for the first instance of that, but Yuck.

What I'm looking for is a nice one liner.

fewer features is better, LINQ is out (for me, don't ask, it's a long story)

The solution I'm going with (unless I see something better)

static int FirstNotMeta(int i, string str)
    for(; i < str.Length; i++)
            case '\\':
            case '/':
            case '.':
                return i;
    return -1;

OK, I cheated, I know in advance what char's I care about.


This works:

public static char FindFirstNotAny(this string value, params char[] charset)
    return value.TrimStart(charset)[0];

Need Your Help

How does Facebook react when someone denies permission to a resource?

php facebook

I'm using the below code for my app. If I deny the permission, I am still able to access the app, but it should not take me to app right?

Navigation bar won't entirely fill screen width

html css

I've started making a navigation bar using the nav tag, which worked perfectly. Using CSS, I set the width of my nav tag to 100%, as well as the border and padding set to 0.