static bool string_filter(RCore *core, const char *str) {
	int i;
	/* pointer/rawdata detection */
	if (core->bin->strpurge) {
		ut8 bo[0x100];
		int up = 0;
		int lo = 0;
		int ot = 0;
		int di = 0;
		int ln = 0;
		int sp = 0;
		int nm = 0;
		for (i = 0; i < 0x100; i++) {
			bo[i] = 0;
		}
		for (i = 0; str[i]; i++) {
			if (IS_DIGIT(str[i])) {
				nm++;
			} else if (str[i]>='a' && str[i]<='z') {
				lo++;
			} else if (str[i]>='A' && str[i]<='Z') {
				up++;
			} else {
				ot++;
			}
			if (str[i]=='\\') {
				ot++;
			}
			if (str[i]==' ') {
				sp++;
			}
			bo[(ut8)str[i]] = 1;
			ln++;
		}
		for (i = 0; i<0x100; i++) {
			if (bo[i]) {
				di++;
			}
		}
		if (ln > 2 && str[0] != '_') {
			if (ln < 10) {
				return false;
			}
			if (ot >= (nm + up + lo)) {
				return false;
			}
			if (lo < 3) {
				return false;
			}
		}
	}

	switch (core->bin->strfilter) {
	case 'U': // only uppercase strings
		for (i = 0; str[i]; i++) {
			char ch = str[i];
			if (ch == ' ') {
				continue;
			}
			if (ch < '@'|| ch > 'Z') {
					return false;
			}
			if (ch < 0 || !IS_PRINTABLE (ch)) {
				return false;
			}
		}
		if (str[0] && str[1]) {
			for (i = 2; i<6 && str[i]; i++) {
				if (str[i] == str[0]) {
					return false;
				}
				if (str[i] == str[1]) {
					return false;
				}
			}
		}
		if (str[0] == str[2]) {
			return false; // rm false positives
		}
		break;
	case 'a': // only alphanumeric - plain ascii
		for (i = 0; str[i]; i++) {
			char ch = str[i];
			if (ch < 1 || !IS_PRINTABLE (ch)) {
				return false;
			}
		}
		break;
	case 'e': // emails
		if (str && *str) {
			if (!strstr (str + 1, "@")) {
				return false;
			}
			if (!strstr (str + 1, ".")) {
				return false;
			}
		} else {
			return false;
		}
		break;
	case 'f': // format-string
		if (str && *str) {
			if (!strstr (str+1, "%"))
				return false;
		} else return false;
		break;
	case 'u': // URLs
		if (!strstr (str, "://")) {
			return false;
		}
		break;
        case 'i': //IPV4
		{
			int segment = 0;
			int segmentsum = 0;
			bool prevd = false;
			for (i = 0; str[i]; i++) {
				char ch = str[i];
				if (IS_DIGIT(ch)) {
					segmentsum = segmentsum*10 + (ch - '0');
					if (segment == 3) {
						return true;
					}
					prevd = true;
				} else if (ch == '.') {
					if (prevd == true && segmentsum < 256){
						segment++;
						segmentsum = 0;
					} else {
						segmentsum = 0;
						segment = 0;
					}
					prevd = false;
				} else {
					segmentsum = 0;
					prevd = false;
					segment = 0;
				}
			}
			return false;
		}
	case 'p': // path
		if (str[0] != '/') {
			return false;
		}
		break;
	case '8': // utf8
		for (i = 0; str[i]; i++) {
			char ch = str[i];
			if (ch < 0) {
				return true;
			}
		}
		return false;
	}
	return true;
}
static bool string_filter(RCore *core, const char *str) {
	int i;
	 
	if (core->bin->strpurge) {
		ut8 bo[0x100];
		int up = 0;
		int lo = 0;
		int ot = 0;
		int di = 0;
		int ln = 0;
		int sp = 0;
		int nm = 0;
		for (i = 0; i < 0x100; i++) {
			bo[i] = 0;
		}
		for (i = 0; str[i]; i++) {
			if (IS_DIGIT(str[i])) {
				nm++;
			} else if (str[i]>='a' && str[i]<='z') {
				lo++;
			} else if (str[i]>='A' && str[i]<='Z') {
				up++;
			} else {
				ot++;
			}
			if (str[i]=='\\') {
				ot++;
			}
			if (str[i]==' ') {
				sp++;
			}
			bo[(ut8)str[i]] = 1;
			ln++;
		}
		for (i = 0; i<0x100; i++) {
			if (bo[i]) {
				di++;
			}
		}
		if (ln > 2 && str[0] != '_') {
			if (ln < 10) {
				return false;
			}
			if (ot >= (nm + up + lo)) {
				return false;
			}
			if (lo < 3) {
				return false;
			}
		}
	}

	switch (core->bin->strfilter) {
	case 'U':  
		for (i = 0; str[i]; i++) {
			char ch = str[i];
			if (ch == ' ') {
				continue;
			}
			if (ch < '@'|| ch > 'Z') {
					return false;
			}
			if (ch < 0 || !IS_PRINTABLE (ch)) {
				return false;
			}
		}
		if (str[0] && str[1]) {
			for (i = 2; i<6 && str[i]; i++) {
				if (str[i] == str[0]) {
					return false;
				}
				if (str[i] == str[1]) {
					return false;
				}
			}
		}
		if (str[0] == str[2]) {
			return false;  
		}
		break;
	case 'a':  
		for (i = 0; str[i]; i++) {
			char ch = str[i];
			if (ch < 1 || !IS_PRINTABLE (ch)) {
				return false;
			}
		}
		break;
	case 'e':  
		if (str && *str) {
			if (!strstr (str + 1, "@")) {
				return false;
			}
			if (!strstr (str + 1, ".")) {
				return false;
			}
		} else {
			return false;
		}
		break;
	case 'f':  
		if (str && *str) {
			if (!strstr (str+1, "%"))
				return false;
		} else return false;
		break;
	case 'u':  
		if (!strstr (str, "://")) {
			return false;
		}
		break;
        case 'i':  
		{
			int segment = 0;
			int segmentsum = 0;
			bool prevd = false;
			for (i = 0; str[i]; i++) {
				char ch = str[i];
				if (IS_DIGIT(ch)) {
					segmentsum = segmentsum*10 + (ch - '0');
					if (segment == 3) {
						return true;
					}
					prevd = true;
				} else if (ch == '.') {
					if (prevd == true && segmentsum < 256){
						segment++;
						segmentsum = 0;
					} else {
						segmentsum = 0;
						segment = 0;
					}
					prevd = false;
				} else {
					segmentsum = 0;
					prevd = false;
					segment = 0;
				}
			}
			return false;
		}
	case 'p':  
		if (str[0] != '/') {
			return false;
		}
		break;
	case '8':  
		for (i = 0; str[i]; i++) {
			char ch = str[i];
			if (ch < 0) {
				return true;
			}
		}
		return false;
	}
	return true;
}