Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created January 28, 2010 00:06
Show Gist options
  • Save stepancheg/288294 to your computer and use it in GitHub Desktop.
Save stepancheg/288294 to your computer and use it in GitHub Desktop.
size_t memspn(const char* s, size_t len, const char* charset) {
for (size_t i = 0; i < len; ++i) {
bool found = false;
for (const char* p = charset; *p != 0; ++p) {
if (s[i] == *p) {
found = true;
break;
}
}
if (!found)
return i;
}
return len;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment