Multi Condition function for Char type

closed account (9y8C5Di1)
I thought this function was so cool, that i wanted to share it.
I have always written like a>='0'&&a<='9'&&a>='a'&&a<='z' in loops etc, but no
more. Basically add whatever you want to condition, and if you want point a to point b just separate them with a '-' sign.
Simply
while(!isCharInside(x,"|a-zA-Z0-9.*/=|-|")){/*code*/}

1
2
3
4
5
6
7
8
bool isCharInside(char check,string condition="a-zA-Z*/+=|-|0-9"){
 for(unsigned int x=0,z=getLenght(condition);x<z;++x){
  if(condition[x+1]=='-'&&(condition[x]!='|'&&condition[x+2]!='|')){
   if(condition[x]>condition[x+2])swap(condition[x],condition[x+2]);
    for(;condition[x]<=condition[x+2];++condition[x]){if(condition[x]==check)return true;};x+=2;}
     else if(check==condition[x])return true; 
}
return false;}
Last edited on
http://cplusplus.com/reference/regex/
A little hard to use but more powerful.
Topic archived. No new replies allowed.